当前位置: 首页>>代码示例>>C++>>正文


C++ CDCHandle::GetDeviceCaps方法代码示例

本文整理汇总了C++中CDCHandle::GetDeviceCaps方法的典型用法代码示例。如果您正苦于以下问题:C++ CDCHandle::GetDeviceCaps方法的具体用法?C++ CDCHandle::GetDeviceCaps怎么用?C++ CDCHandle::GetDeviceCaps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDCHandle的用法示例。


在下文中一共展示了CDCHandle::GetDeviceCaps方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _ResizeWindow

void WeaselPanel::_ResizeWindow()
{
	if (!m_status.composing)
	{
		SetWindowPos( NULL, 0, 0, STATUS_ICON_SIZE, STATUS_ICON_SIZE, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
		return;
	}
	CDCHandle dc = GetDC();
	long fontHeight = -MulDiv(m_style.font_point, dc.GetDeviceCaps(LOGPIXELSY), 72);
	CFont font;
	font.CreateFontW(fontHeight, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, m_style.font_face.c_str());
	dc.SelectFont(font);

	CSize size = m_layout->GetContentSize();
	SetWindowPos(NULL, 0, 0, size.cx, size.cy, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
	dc.DeleteDC();
}
开发者ID:wlnetman,项目名称:weasel,代码行数:17,代码来源:WeaselPanel.cpp

示例2: Refresh

//¸üнçÃæ
void WeaselPanel::Refresh()
{
	if (m_layout != NULL)
		delete m_layout;
	if (m_style.layout_type == LAYOUT_VERTICAL)
		m_layout = new VerticalLayout(m_style, m_ctx);
	else if (m_style.layout_type == LAYOUT_HORIZONTAL)
		m_layout = new HorizontalLayout(m_style, m_ctx);
	CDCHandle dc = GetDC();
	long fontHeight = -MulDiv(m_style.font_point, dc.GetDeviceCaps(LOGPIXELSY), 72);
	CFont font;
	font.CreateFontW(fontHeight, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, m_style.font_face.c_str());
	dc.SelectFont(font);
	m_layout->DoLayout(dc);
	dc.DeleteDC();

	_ResizeWindow();
	_RepositionWindow();
	RedrawWindow();
}
开发者ID:wlnetman,项目名称:weasel,代码行数:21,代码来源:WeaselPanel.cpp

示例3: CalcLayout

bool CPrintFolder::CalcLayout(CDCHandle dcPrinter)
{
	if(!dcPrinter.IsNull())
	{
		CRect rcPage(0, 0, 
		dcPrinter.GetDeviceCaps(PHYSICALWIDTH) - 2 * dcPrinter.GetDeviceCaps(PHYSICALOFFSETX),
		dcPrinter.GetDeviceCaps(PHYSICALHEIGHT) - 2 * dcPrinter.GetDeviceCaps(PHYSICALOFFSETY));
		
		// Fix for 98...PHYSICALWIDTH seems to fail on 98?
		if (rcPage.right == 0) 
		{
			rcPage.right = dcPrinter.GetDeviceCaps(HORZRES);
			rcPage.bottom = dcPrinter.GetDeviceCaps(VERTRES);
		}

		return CalcLayout(dcPrinter, rcPage);
	}
	
	return CalcLayout(dcPrinter, m_rcOutput);
}
开发者ID:ZacWalk,项目名称:ImageWalker,代码行数:20,代码来源:PrintFolder.cpp

示例4: OnEraseBackground

LRESULT CAnimMixer::OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	drawBar(1);

  CDCHandle dc = (HDC) wParam;

	// prepare...
	CRect rc;
  GetClientRect(&rc);

	CFontHandle oldFont = dc.SelectFont(AtlGetDefaultGuiFont());
	dc.SetTextColor(RGB(0, 0, 0));
	dc.SetBkMode(TRANSPARENT);

	CPen blackPen;
	blackPen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	CPenHandle oldPen = dc.SelectPen(blackPen);

	// fill background
	dc.FillSolidRect(&rc, RGB(174, 169, 167));

	// draw tl bar at y 45
	dc.MoveTo(mapTime(0), 45);
	dc.LineTo(rc.right, 45);

	// track grid
	CPen pen_grid;
	pen_grid.CreatePen(PS_DOT, 1, RGB(174*3/4, 169*3/4, 167*3/4)^RGB(174, 169, 167));

	dc.SelectPen(pen_grid);
	dc.SetROP2(R2_XORPEN);
	dc.SetBkColor(RGB(0, 0, 0));
	dc.SetBkMode(TRANSPARENT);

	for (sInt trackY=46+22; trackY<rc.bottom; trackY+=22)
	{
		dc.MoveTo(mapTime(0), trackY);
		dc.LineTo(rc.right, trackY);
	}

	// bar marks
	dc.SetROP2(R2_COPYPEN);
	dc.SelectPen(blackPen);

	const sF32 xstep = 60000.0f / g_graph->m_bpmRate;
	const sF32 ixstep = g_graph->m_bpmRate / (60000.0f * m_frameStep);
	const sInt xms = (m_startPixel) * ixstep;
	const sInt xme = (m_startPixel + rc.right) * ixstep;

	LOGFONT lf;
	((CFontHandle) AtlGetDefaultGuiFont()).GetLogFont(lf);

	if (lf.lfHeight<0)
		lf.lfHeight=MulDiv(-lf.lfHeight, dc.GetDeviceCaps(LOGPIXELSY), 72);

	for (sInt i=fr::maximum(xms-1,0); i<=xme+1; i++)
	{
		const sInt xpos=mapTime(i*xstep);

		const sInt beat=i&3;

		dc.MoveTo(xpos, 45);
		dc.LineTo(xpos, 37-(beat==0)*2);

		TCHAR buf[32];
		sprintf(buf, "%d.%d", i/4, beat);

		dc.SetTextAlign(TA_BOTTOM|(i?TA_CENTER:TA_LEFT));
		dc.TextOut(xpos, 35, buf);

		if (!beat)
		{
			dc.MoveTo(xpos, rc.bottom);
			dc.LineTo(xpos, 45);
		}
	}

	dc.SelectPen(oldPen);
	dc.SelectFont(oldFont);

  return 1;
}
开发者ID:Ambrevar,项目名称:fr_public,代码行数:82,代码来源:AnimMixer.cpp

示例5: DoPaint

//draw client area
void WeaselPanel::DoPaint(CDCHandle dc)
{
	CRect rc;
	GetClientRect(&rc);

	if (!m_status.composing)
	{
		if (m_status.ascii_mode)
			dc.DrawIconEx(0, 0, m_iconAlpha, 0, 0);
		else
			dc.DrawIconEx(0, 0, m_iconEnabled, 0, 0); 
		return;
	}

	// background
	{
		CBrush brush;
		brush.CreateSolidBrush(m_style.back_color);
		CRgn rgn;
		rgn.CreateRectRgnIndirect(&rc);
		dc.FillRgn(rgn, brush);

		CPen pen;
		pen.CreatePen(PS_SOLID | PS_INSIDEFRAME, m_style.border, m_style.border_color);
		CPenHandle oldPen = dc.SelectPen(pen);
		CBrushHandle oldBrush = dc.SelectBrush(brush);
		dc.Rectangle(&rc);
		dc.SelectPen(oldPen);
		dc.SelectBrush(oldBrush);
	}

	long height = -MulDiv(m_style.font_point, dc.GetDeviceCaps(LOGPIXELSY), 72);

	CFont font;
	font.CreateFontW(height, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, m_style.font_face.c_str());
	CFontHandle oldFont = dc.SelectFont(font);

	dc.SetTextColor(m_style.text_color);
	dc.SetBkColor(m_style.back_color);
	dc.SetBkMode(TRANSPARENT);
	
	bool drawn = false;

	// draw preedit string
	if (!m_style.inline_preedit)
		drawn |= _DrawPreedit(m_ctx.preedit, dc, m_layout->GetPreeditRect());
	
	/* FIXME: What's this?
	// ascii mode icon
	if (m_status.ascii_mode && y > rc.top)
	{
		int icon_x = rc.right - STATUS_ICON_SIZE;
		int icon_y = (rc.top + y - m_style.spacing - STATUS_ICON_SIZE) / 2;
		dc.DrawIconEx(icon_x, icon_y, m_iconAlpha, 0, 0);
	}*/

	/* TODO: Deprecated? */
	// draw auxiliary string
	drawn |= _DrawPreedit(m_ctx.aux, dc, m_layout->GetAuxiliaryRect());

	// draw candidates
	drawn |= _DrawCandidates(dc);

	/* Nothing drawn, hide candidate window */
	if (!drawn)
		ShowWindow(SW_HIDE);

	dc.SelectFont(oldFont);	
}
开发者ID:wlnetman,项目名称:weasel,代码行数:70,代码来源:WeaselPanel.cpp

示例6: DrawImage

bool CPrintFolder::DrawImage(CDCHandle dc, CPoint point, IW::Image &image, IW::FolderItem *pItem)
{
	HFONT hOldFont = dc.SelectFont(m_font);
	UINT uTextStyle =  DT_NOPREFIX | DT_EDITCONTROL;
	if (m_bCenter) uTextStyle |= DT_CENTER;
	if (!m_bWrap) uTextStyle |= DT_WORD_ELLIPSIS; else uTextStyle |= DT_WORDBREAK;

	// Calc Text Size
	CSimpleArray<CString> arrayStrText;
	CSimpleValArray<int> arrayHeights;
	pItem->GetFormatText(arrayStrText, m_annotations, true);

	int i, nHeightText = 0;

	for(i = 0; i < arrayStrText.GetSize(); i++)
	{
		CRect r(point.x, 
			point.y + _sizeSection.cy, 
			point.x + _sizeSection.cx, 
			point.y + _sizeSection.cy);

		dc.DrawText(arrayStrText[i], -1,
			&r, uTextStyle | DT_CALCRECT);

		int nLimit = _sizeThumbNail.cy / 2;
		if (nHeightText + r.Height() > nLimit) 
		{
			arrayHeights.Add(nLimit - nHeightText);
			nHeightText = nLimit;
			break;
		}
		else
		{
			nHeightText += r.Height();
			arrayHeights.Add(r.Height());
		}
	}

	CSize sizeThumbNailLocal = _sizeThumbNail;	
	sizeThumbNailLocal.cy -= nHeightText;

	if (!image.IsEmpty())
	{
		IW::Page page = image.GetFirstPage();

		// Best fit rotate
		if (m_nPrintRotateBest > 0)
		{
			bool bRotate = ((sizeThumbNailLocal.cx > sizeThumbNailLocal.cy) &&
				(page.GetWidth() < page.GetHeight())) || 
				((sizeThumbNailLocal.cx < sizeThumbNailLocal.cy) &&
				(page.GetWidth() > page.GetHeight()));

			if (bRotate)
			{
				IW::Image imageRotate;

				if (m_nPrintRotateBest == 1)
				{
					IW::Rotate270(image, imageRotate, _pStatus);
				}
				else
				{
					IW::Rotate90(image, imageRotate, _pStatus);
				}

				image = imageRotate;
			}
		}	

		const int nSizeAverage = (page.GetWidth() + page.GetHeight()) / 2;

		page = image.GetFirstPage();
		page.SetBackGround(m_clrBackGround);

		const CRect rectBounding = image.GetBoundingRect();

		const int nWidthPels = dc.GetDeviceCaps(HORZRES); 
		const int nHeightPels = dc.GetDeviceCaps(VERTRES); 

		const long icx = rectBounding.Width();
		const long icy = rectBounding.Height();
		const long nDiv = 0x1000;		
		
		// Scale the image
		long sh = MulDiv(sizeThumbNailLocal.cx, nDiv, icx);
		long sw = MulDiv(sizeThumbNailLocal.cy, nDiv, icy);		
		long s =  IW::Min(sh, sw);
		
		const CSize sizeImage(MulDiv(page.GetWidth(), s, nDiv), MulDiv(page.GetHeight(), s, nDiv));		
		const CPoint pt(point.x + ((sizeThumbNailLocal.cx - sizeImage.cx) / 2) + m_nPadding,
			point.y + ((sizeThumbNailLocal.cy - sizeImage.cy) / 2) + m_nPadding);

		const CRect rectPrint(pt, sizeImage);

		if ((rectPrint.Width() < page.GetWidth()) && (rectPrint.Height() < page.GetHeight()))
		{
			IW::Image imageScaled;
			IW::Scale(image, imageScaled, rectPrint.Size(), _pStatus);
			image = imageScaled;
//.........这里部分代码省略.........
开发者ID:ZacWalk,项目名称:ImageWalker,代码行数:101,代码来源:PrintFolder.cpp


注:本文中的CDCHandle::GetDeviceCaps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。