本文整理汇总了C++中CClientDC::SelectStockObject方法的典型用法代码示例。如果您正苦于以下问题:C++ CClientDC::SelectStockObject方法的具体用法?C++ CClientDC::SelectStockObject怎么用?C++ CClientDC::SelectStockObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CClientDC
的用法示例。
在下文中一共展示了CClientDC::SelectStockObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 ();
}
示例2: 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);
}
示例3: AdjustControl
//************************************************************************************************
void CBCGPDateTimeCtrl::AdjustControl (CRect rectClient)
{
if (GetSafeHwnd () == NULL)
{
return;
}
CClientDC dc (this);
CFont* pPrevFont = m_hFont == NULL ?
(CFont*) dc.SelectStockObject (DEFAULT_GUI_FONT) :
dc.SelectObject (CFont::FromHandle (m_hFont));
if (m_WidestDate == COleDateTime ())
{
BuidWidestDate (&dc);
}
SetPartsOrder ();
m_iPartNum = m_bCheckBoxIsAvailable ? 1 : 0;
m_CurrPartType = m_arPartsOrder [m_iPartNum];
m_rectText = rectClient;
m_rectText.InflateRect (0, -2);
if (m_bAutoResize)
{
// Calculate text size:
TEXTMETRIC tm;
dc.GetTextMetrics (&tm);
m_iControlHeight = tm.tmHeight + 6;
}
else
{
m_iControlHeight = rectClient.Height ();
}
if (m_bCheckBoxIsAvailable)
{
m_rectCheck = CRect (rectClient.left + 1, rectClient.top + 1,
rectClient.left + m_iControlHeight - 1, rectClient.bottom - 1);
m_rectText.left = m_rectCheck.right + 2;
}
m_rectText.top = rectClient.top;
m_rectText.bottom = rectClient.top + m_iControlHeight;
// Calculate parts:
CalcPartRects (&dc);
// Adjust control size:
m_rectText.right = m_arPartRects [m_iPartsNumber - 1].right + 2;
m_iControlWidth = m_rectText.right;
if (m_spinButton)
{
m_iControlWidth += iSpinWidth;
}
if (!m_bAutoResize)
{
m_iControlWidth = rectClient.Width ();
m_iControlHeight = rectClient.Height ();
}
if (m_dropCalendar && m_showDate)
{
if (m_bAutoResize)
{
m_iControlWidth += iDropButtonWidth;
}
int iDropStart = rectClient.left + m_iControlWidth - iDropButtonWidth - 1;
if (m_spinButton)
{
iDropStart -= iSpinWidth + 1;
}
m_rectDropButton = CRect ( iDropStart,
rectClient.top,
iDropStart + iDropButtonWidth,
rectClient.top + m_iControlHeight - 2);
}
if (m_bAutoResize)
{
SetWindowPos (NULL, -1, -1, m_iControlWidth + 2, m_iControlHeight + 2,
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);
}
// Adjust spin button:
if (m_spinButton)
{
if (m_wndSpin.GetSafeHwnd () == NULL)
{
m_wndSpin.Create (WS_CHILD | WS_VISIBLE | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,
//.........这里部分代码省略.........
示例4: Track
//*******************************************************************************************
void CLoginBarToolTipCtrl::Track (CRect rect, const CString& strText)
{
if (GetSafeHwnd () == NULL)
{
return;
}
if (m_rectLast == rect && m_strText == strText)
{
return;
}
ASSERT_VALID (m_pWndParent);
m_rectLast = rect;
m_strText = strText;
CClientDC dc (this);
//ASSERT_VALID(m_pFont);
CFont* pPrevFont = m_pFont == NULL ?
(CFont*) dc.SelectStockObject (DEFAULT_GUI_FONT) :
dc.SelectObject (&theApp.m_font);
ASSERT (pPrevFont != NULL);
int nTextHeight = rect.Height () ;
int nTextWidth = rect.Width ();
if (m_strText.FindOneOf (_T("\n")) != -1) // multi-line tooltip
{
const int nDefaultHeight = globalData.GetTextHeight () ;
const int nDefaultWidth = 200;
CRect rectText (0, 0, nDefaultWidth, nDefaultHeight);
nTextHeight = dc.DrawText (m_strText, rectText, DT_LEFT | /*DT_WORDBREAK | */DT_CALCRECT | DT_NOPREFIX);
nTextWidth = rectText.Width ();
nTextHeight += 2 * m_nTextMargin ;
nTextWidth += 2 * m_nTextMargin;
nTextHeight += (GetLineCount(m_strText) - 1) * m_nTextMargin; //加上行间距
}
else
{
nTextWidth = dc.GetTextExtent (m_strText).cx + 2 * m_nTextMargin;
}
dc.SelectObject (pPrevFont);
if (m_pWndParent->GetExStyle () & WS_EX_LAYOUTRTL)
{
rect.left = rect.right - nTextWidth;
}
else
{
rect.right = rect.left + nTextWidth;
}
rect.bottom = rect.top + nTextHeight;
if (rect.Height () < m_rectLast.Height ())
{
rect.top = m_rectLast.top;
rect.bottom = m_rectLast.bottom;
}
MONITORINFO mi;
mi.cbSize = sizeof (MONITORINFO);
CRect rectScreen;
if (GetMonitorInfo (MonitorFromPoint (rect.TopLeft (), MONITOR_DEFAULTTONEAREST), &mi))
{
rectScreen = mi.rcWork;
}
else
{
::SystemParametersInfo (SPI_GETWORKAREA, 0, &rectScreen, 0);
}
if (rect.Width () > rectScreen.Width ())
{
rect.left = rectScreen.left;
rect.right = rectScreen.right;
}
else if (rect.right > rectScreen.right)
{
rect.OffsetRect( rectScreen.right - rect.right, 0 );
//rect.right = rectScreen.right;
//rect.left = rect.right - nTextWidth;
}
else if (rect.left < rectScreen.left)
{
rect.OffsetRect( rectScreen.left - rect.left, 0 );
//rect.left = rectScreen.left;
//rect.right = rect.left + nTextWidth;
}
if (rect.Height () > rectScreen.Height ())
{
rect.top = rectScreen.top;
rect.bottom = rectScreen.bottom;
}
else if (rect.bottom > rectScreen.bottom)
//.........这里部分代码省略.........