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


C++ CClientDC::SelectObject方法代码示例

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


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

示例1: MeasureItem

void CaImMenu::MeasureItem (LPMEASUREITEMSTRUCT lpMeasureItemStruct) {
	MENUITEMINFO iInfo;
	GetMenuItemInfo (lpMeasureItemStruct->CtlID, &iInfo);
	CaImMenuItem* pItem = (CaImMenuItem*)lpMeasureItemStruct->itemData;

	CFont fntDef;
	LOGFONT lfDef;
	CClientDC dc (0);
	CFont* pFont = (CFont *)dc.SelectStockObject (ANSI_VAR_FONT);
	if (pItem->CheckStyle (AMIS_DEFAULT)) {
		CFont* pFnt = dc.GetCurrentFont ();
		pFnt->GetLogFont (&lfDef);
		lfDef.lfWeight = FW_BOLD;
		fntDef.CreateFontIndirect (&lfDef);
		dc.SelectObject (&fntDef);
	}

	if (pItem->CheckStyle (AMIS_BAR))
		lpMeasureItemStruct->itemHeight = 4;
	else
		lpMeasureItemStruct->itemHeight = m_dwHeight;
	lpMeasureItemStruct->itemWidth = 25 + 8 + 8 + 2 + dc.GetTextExtent (pItem->GetText ()).cx;

	dc.SelectObject (pFont);
	if (pItem->CheckStyle (AMIS_DEFAULT))
		fntDef.DeleteObject ();
}
开发者ID:macx0r,项目名称:dias-inet,代码行数:27,代码来源:aimmenu.cpp

示例2: eraseDataText

void CComputer::eraseDataText(CClientDC &dc)
{
	dc.SetTextColor(white);
	originalFont = dc.SelectObject(&dataFont);
	drawDataText(dc);
	dc.SelectObject(&originalFont);
}
开发者ID:flomar,项目名称:CrypTool-VS2015,代码行数:7,代码来源:Computer.cpp

示例3: DrawCell

void CMainFrame::DrawCell (UINT col,UINT row,BOOL alive)
{
	CBrush* pBrush;
	CClientDC clientDC (this);
	CDC memDC;
	memDC.CreateCompatibleDC (&clientDC);
	memDC.SelectObject (m_pBitmap);

	if(alive)
		pBrush=new CBrush(RGB(255, 0, 0));
	else
	{	
		if (m_showdead)
			pBrush=new CBrush(RGB(200, 200, 200));
		else
			pBrush=new CBrush(RGB(255, 255, 255));
	}

	CBrush* pOldBrush1=memDC.SelectObject (pBrush);
	CBrush* pOldBrush2=clientDC.SelectObject (pBrush);

	UINT drawCol= col * SQUARESIZE + HOROFFSET;
	UINT drawRow= row * SQUARESIZE + VEROFFSET;

	memDC.Rectangle (drawCol,drawRow,drawCol+SQUARESIZE+1, drawRow+SQUARESIZE+1);
	clientDC.Rectangle (drawCol,drawRow,drawCol+SQUARESIZE+1, drawRow+SQUARESIZE+1);

	memDC.SelectObject (pOldBrush1);
	clientDC.SelectObject (pOldBrush2);

	delete pBrush;
}
开发者ID:BorisMomtchev,项目名称:ConwaysLife,代码行数:32,代码来源:mainfrm.cpp

示例4: OnMeasureItem

//*****************************************************************************************
void CIconCombo::OnMeasureItem(int /*nIDCtl*/, LPMEASUREITEMSTRUCT lpMeasureItemStruct) 
{
	int nTextWidth = 0;
	int nTextHeight = 0;

	if (!m_lstIconNames.IsEmpty ())
	{
		nTextHeight = globalData.GetTextHeight ();

		CClientDC dc (this);
		CFont* pOldFont = dc.SelectObject (&globalData.fontRegular);

		for (POSITION pos = m_lstIconNames.GetHeadPosition (); pos != NULL;)
		{
			CString str = m_lstIconNames.GetNext (pos);

			nTextWidth = max (nTextWidth, dc.GetTextExtent (str).cx + nIconMargin);
		}

		dc.SelectObject (pOldFont);
	}

	lpMeasureItemStruct->itemWidth = m_imageListIcons.GetImageSize ().cx + nTextWidth + 3 * nIconMargin;
	lpMeasureItemStruct->itemHeight = max (nTextHeight, m_imageListIcons.GetImageSize ().cy + 2 * nIconMargin);
}
开发者ID:zxlooong,项目名称:bcgexp,代码行数:26,代码来源:customcells.cpp

示例5: GetOptimalTextSize

CSize CBCGPPopupDlg::GetOptimalTextSize (CString str)
{
	if (str.IsEmpty ())
	{
		return CSize (0, 0);
	}

	CRect rectScreen;

	CRect rectDlg;
	GetWindowRect (rectDlg);

	MONITORINFO mi;
	mi.cbSize = sizeof (MONITORINFO);
	if (GetMonitorInfo (MonitorFromPoint (rectDlg.TopLeft (), MONITOR_DEFAULTTONEAREST), &mi))
	{
		rectScreen = mi.rcWork;
	}
	else
	{
		::SystemParametersInfo (SPI_GETWORKAREA, 0, &rectScreen, 0);
	}

	CClientDC dc (this);

	CFont* pOldFont = dc.SelectObject (&globalData.fontRegular);
	ASSERT_VALID (pOldFont);

	int nStepY = globalData.GetTextHeight ();
	int nStepX = nStepY * 3;

	CRect rectText (0, 0, nStepX, nStepY);

	for (;;)
	{
		CRect rectTextSaved = rectText;

		int nHeight = dc.DrawText (str, rectText, DT_CALCRECT | DT_WORDBREAK | DT_NOPREFIX);
		int nWidth = rectText.Width ();

		rectText = rectTextSaved;

		if (nHeight <= rectText.Height () ||
			rectText.Width () > rectScreen.Width () ||
			rectText.Height () > rectScreen.Height ())
		{
			rectText.bottom = rectText.top + nHeight + 5;
			rectText.right = rectText.left + nWidth + 5;
			break;
		}

		rectText.right += nStepX;
		rectText.bottom += nStepY;
	}

	dc.SelectObject (pOldFont);
	return rectText.Size ();
}
开发者ID:cugxiangzhenwei,项目名称:WorkPlatForm,代码行数:58,代码来源:BCGPPopupDlg.cpp

示例6: erase

void CPacket::erase(CClientDC &dc)
{
	originalPen = dc.SelectObject(&whitePen);
	
	dc.Rectangle(x1,y1,x2,y2);
	
	dc.MoveTo(x1,y1);
	dc.LineTo(x2,y2);
	dc.MoveTo(x1,y2);
	dc.LineTo(x2,y1);

	dc.SelectObject(&originalPen);
}
开发者ID:flomar,项目名称:CrypTool-VS2015,代码行数:13,代码来源:Packet.cpp

示例7: UpdateDisplay

void CDlgCalcDlg::UpdateDisplay(LPCTSTR pszDisplay)
{
    CClientDC dc (this);
    CFont* pOldFont = dc.SelectObject (GetFont ());
    CSize size = dc.GetTextExtent (pszDisplay);

    CRect rect = m_rect;
    rect.InflateRect (-2, -2);
    int x = rect.right - size.cx - m_cxChar;
    int y = rect.top + ((rect.Height () - m_cyChar) / 2);

    dc.ExtTextOut (x, y, ETO_OPAQUE, rect, pszDisplay, NULL);
    dc.SelectObject (pOldFont);
}
开发者ID:jiayuehua,项目名称:MFCProgramming,代码行数:14,代码来源:DlgCalcDlg.cpp

示例8: draw

void CPacket::draw(CClientDC &dc)
{
	if (visible||active){
		originalPen = dc.SelectObject(&blackPen);
	}else{
		originalPen = dc.SelectObject(&whitePen);
	}
	dc.Rectangle(x1,y1,x2,y2);
	
	dc.MoveTo(x1+1,y1+1);
	dc.LineTo(x2-1,y2-1);
	dc.MoveTo(x1+1,y2-1);
	dc.LineTo(x2-1,y1+1);

	dc.SelectObject(&originalPen);
}
开发者ID:flomar,项目名称:CrypTool-VS2015,代码行数:16,代码来源:Packet.cpp

示例9: OnShowPopupMenu

void CRibbonListButton::OnShowPopupMenu ()
{
	ASSERT_VALID (this);

	CBCGPBaseRibbonElement::OnShowPopupMenu ();

	if (m_sizeMaxText == CSize (0, 0))
	{
		CBCGPRibbonBar* pRibbonBar = GetTopLevelRibbonBar ();
		ASSERT_VALID (pRibbonBar);

		CClientDC dc (pRibbonBar);

		CFont* pOldFont = dc.SelectObject (pRibbonBar->GetFont ());
		ASSERT (pOldFont != NULL);

		int i = 0;

		for (i = 0; i < m_arLabels.GetSize (); i++)
		{
			CSize szText = dc.GetTextExtent (m_arLabels [i]);

			m_sizeMaxText.cx = max (m_sizeMaxText.cx, szText.cx);
			m_sizeMaxText.cy = max (m_sizeMaxText.cy, szText.cy);
		}

		const int cxImage = m_listImages.GetImageSize ().cx;

		for (i = 0; i < m_arSubItems.GetSize (); i++)
		{
			CBCGPBaseRibbonElement* pButton = m_arSubItems [i];
			ASSERT_VALID (pButton);

			CString strText = pButton->GetText ();
			CSize szText = dc.GetTextExtent (strText);

			m_sizeMaxText.cx = max (m_sizeMaxText.cx, szText.cx - cxImage);
		}

		dc.SelectObject (pOldFont);
	}

	CBCGPRibbonPaletteButton::OnShowPopupMenu ();
}
开发者ID:zxlooong,项目名称:bcgexp,代码行数:44,代码来源:RibbonListButton.cpp

示例10: OnPaint

void CMyStatusBar::OnPaint() 
{
	Default();

    CClientDC cDC (this);
	CPen pen(PS_SOLID, 1, ::GetSysColor (COLOR_3DSHADOW));
	HPEN oldPen = (HPEN)cDC.SelectObject(pen);

    CRect rcItem;

    cDC.SelectObject (::GetStockObject (NULL_BRUSH));

    for ( int i = 0; i < m_nCount; i++ )
    {
        GetItemRect (i, rcItem);
        cDC.Rectangle (rcItem); 
    }
	cDC.SelectObject (oldPen);
}
开发者ID:Quetzaloid,项目名称:LaserScanXXX,代码行数:19,代码来源:MyStatusBar.cpp

示例11: OnSetText

//////////////////
// text changed: resize window to fit
//
LRESULT CPopupText::OnSetText(WPARAM wp, LPARAM lp)
{
	UNREFERENCED_PARAMETER (wp);

	CClientDC dc = this;
	CFont* pOldFont = dc.SelectObject(&m_font);
	CRect rc;
	GetWindowRect(&rc);
	int x = (m_nStyle & JUSTIFYRIGHT) ? rc.right : rc.left;
	int y = rc.top;
	dc.DrawText(CString((LPCTSTR)lp), &rc, DT_CALCRECT);
	rc.InflateRect(m_szMargins);
	if (m_nStyle & JUSTIFYRIGHT)
		x -= rc.Width();
	SetWindowPos(NULL,x,y,rc.Width(),rc.Height(), SWP_NOZORDER|SWP_NOACTIVATE);
	dc.SelectObject (pOldFont);

	return Default();
}
开发者ID:ruglcc,项目名称:gbnx31_tool,代码行数:22,代码来源:PupText.cpp

示例12: SetColumnsWidth

//*************************************************************************************
void CBCGPKeyMapDlg::SetColumnsWidth ()
{
	CRect rectList;
	m_KeymapList.GetClientRect (rectList);

	CClientDC dc (this);
	CFont* pOldFont = dc.SelectObject (m_KeymapList.GetFont ());
	ASSERT_VALID (pOldFont);

	int nKeyColumWidth = dc.GetTextExtent (CString (_T("Ctrl+Shift+W"))).cx + 10;

	dc.SelectObject (pOldFont);

	int nRestOfWidth = rectList.Width () - nKeyColumWidth - ::GetSystemMetrics (SM_CXHSCROLL);

	m_KeymapList.SetColumnWidth (iColumnCommand, nRestOfWidth / 3);
	m_KeymapList.SetColumnWidth (iColumnKeys, nKeyColumWidth);
	m_KeymapList.SetColumnWidth (iColumnDescr, nRestOfWidth * 2 / 3);
}
开发者ID:iclosure,项目名称:jframework,代码行数:20,代码来源:BCGPKeyMapDlg.cpp

示例13: draw

void CComputer::draw(CClientDC &dc)
{
	if (visible){
		if ((isAttacker)||(underAttack)){
			originalPen = dc.SelectObject(&redPen);
			dc.SetTextColor(red);
		}else{
			originalPen = dc.SelectObject(&bluePen);
			dc.SetTextColor(black);
		}
	}else{
		originalPen = dc.SelectObject(&whitePen);
		dc.SetTextColor(white);
	}


	originalFont = dc.SelectObject(&captionFont);
	dc.SetBkMode(TRANSPARENT);
	
	dc.Rectangle(x1,y1,x2,y2);
	if (textPosition == 0){//oben
		dc.TextOut(x1-4*borderWidth,y1-(borderWidth+captionTextSize),name);
	}else{//rechts unten
		dc.TextOut(x2+3*borderWidth,y2+borderWidth-captionTextSize,name);
	}
	
	drawDataText(dc);

	dc.SelectObject(&originalFont);
	dc.SelectObject(&originalPen);
}
开发者ID:flomar,项目名称:CrypTool-VS2015,代码行数:31,代码来源:Computer.cpp

示例14: OnCreate

int CUndoBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CBCGPPopupMenuBar::OnCreate(lpCreateStruct) == -1)
		return -1;

	CFont* pMenuFont = (CFont*) &CBCGPMenuBar::GetMenuFont ();

	//------------------
	// Set label height:
	//------------------
	CClientDC dc (this);
	CFont* pOldFont = dc.SelectObject (pMenuFont);

	TEXTMETRIC tm;
	dc.GetTextMetrics (&tm);

	m_nLabelHeight = tm.tmHeight + 2;

	dc.SelectObject (pOldFont);

	CRect rectDummy (0, 0, 0, 0);
	m_wndList.Create (WS_VISIBLE | WS_CHILD | LBS_NOINTEGRALHEIGHT | LBS_NOTIFY | WS_VSCROLL | LBS_MULTIPLESEL, 
						rectDummy, this, ID_LIST);
	m_wndList.ModifyStyleEx (0, WS_EX_CLIENTEDGE);

	m_wndList.SetFont (pMenuFont);

	CUndoButton* pUndoButton = GetParentButton ();
	ASSERT_VALID (pUndoButton);

	for (POSITION pos = pUndoButton->m_lstActions.GetHeadPosition (); pos != NULL;)
	{
		m_wndList.AddString (pUndoButton->m_lstActions.GetNext (pos));
	}

	return 0;
}
开发者ID:zxlooong,项目名称:bcgexp,代码行数:37,代码来源:UndoBar.cpp

示例15: MeasureItem

//******************************************************************************
void CBCGPRibbonCommandsListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMIS)
{
	ASSERT (lpMIS != NULL);

	CClientDC dc (this);
	CFont* pOldFont = (CFont*) dc.SelectStockObject (DEFAULT_GUI_FONT);
	ASSERT_VALID (pOldFont);

	TEXTMETRIC tm;
	dc.GetTextMetrics (&tm);

	lpMIS->itemHeight = tm.tmHeight + 6;

	dc.SelectObject (pOldFont);
}
开发者ID:iclosure,项目名称:jframework,代码行数:16,代码来源:BCGPRibbonCommandsListBox.cpp


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