本文整理汇总了C++中CDCHandle::GetCurrentFont方法的典型用法代码示例。如果您正苦于以下问题:C++ CDCHandle::GetCurrentFont方法的具体用法?C++ CDCHandle::GetCurrentFont怎么用?C++ CDCHandle::GetCurrentFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDCHandle
的用法示例。
在下文中一共展示了CDCHandle::GetCurrentFont方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawGlowText
int CSkinManager::DrawGlowText(CDCHandle hdc, LPCTSTR lpchText, int cchText, LPRECT lprc, UINT format, bool bGlow)
{
const int iGlowMargin = 10;
CDC dcMem;
dcMem.CreateCompatibleDC(hdc);
CBitmap bmp;
BITMAPINFO dib = { sizeof(BITMAPINFOHEADER), lprc->right - lprc->left + iGlowMargin + iGlowMargin, lprc->top - lprc->bottom, 1, 32, BI_RGB };
bmp.CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
dcMem.SelectBitmap(bmp);
__DTTOPTS dto = { sizeof(__DTTOPTS) };
dto.dwFlags = _DTT_TEXTCOLOR | _DTT_COMPOSITED | (bGlow ? _DTT_GLOWSIZE : 0);
dto.crText = hdc.GetTextColor();
dto.iGlowSize = 8;
dcMem.SelectFont(hdc.GetCurrentFont());
RECT rcText2 = { iGlowMargin, 0, lprc->right - lprc->left + iGlowMargin, lprc->bottom - lprc->top };
int iRet = ::TuoDrawThemeTextEx(s()->GetTheme(), dcMem, 0, 0, lpchText, cchText, format, &rcText2, &dto);
BLENDFUNCTION bf;
bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0;
bf.SourceConstantAlpha = 0xff;
bf.AlphaFormat = AC_SRC_ALPHA;
::AlphaBlend(hdc, lprc->left - iGlowMargin, lprc->top, lprc->right - lprc->left + iGlowMargin + iGlowMargin, lprc->bottom - lprc->top, dcMem, 0, 0, lprc->right - lprc->left + iGlowMargin + iGlowMargin, lprc->bottom - lprc->top, bf);
return iRet;
}
示例2: rect
void
CNdasMenuBitmapHandler::
OnDrawStatusText(
LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDCHandle dc = lpDrawItemStruct->hDC;
CRect rect(&lpDrawItemStruct->rcItem);
rect.bottom -= 2;
COLORREF oldBkColor = dc.SetBkColor(RGB(255,255,225));
CBrush brush = ::CreateSolidBrush(RGB(255,255,225));
CPen pen = ::CreatePen(PS_SOLID, 1, ::GetSysColor(COLOR_3DDKSHADOW));
HBRUSH hOldBrush = dc.SelectBrush(brush);
HPEN hOldPen = dc.SelectPen(pen);
// dc.Rectangle(rect);
dc.RoundRect(rect,CPoint(rect.Height() /4, rect.Height() / 4));
(void) dc.SelectPen(hOldPen);
(void) dc.SelectBrush(hOldBrush);
CRect rectText(rect);
rectText.left += GetSystemMetrics(SM_CXMENUCHECK) + 2;
CString strStatus;
ATLVERIFY(strStatus.LoadString(static_cast<UINT>(lpDrawItemStruct->itemData)));
CFontHandle curFont = dc.GetCurrentFont();
LOGFONT logFont;
curFont.GetLogFont(&logFont);
logFont.lfWeight = FW_BOLD;
CFont newFont = ::CreateFontIndirect(&logFont);
CFontHandle oldFont = dc.SelectFont(newFont);
// COLORREF oldTextColor = dc.SetTextColor(RGB(40,40,233));
dc.DrawText(
strStatus,
strStatus.GetLength(),
&rectText,
DT_SINGLELINE | DT_WORD_ELLIPSIS | DT_NOPREFIX |
DT_VCENTER);
dc.SelectFont(oldFont);
// dc.SetTextColor(oldTextColor);
dc.SetBkColor(oldBkColor);
}
示例3: if
//.........这里部分代码省略.........
rc.left += cx;
}
if( pItem->mask & TLVIF_TEXT ) {
rc.left += 2;
COLORREF clrText = lptvcd->clrText;
if( pItem->mask & TLVIF_TEXTCOLOR ) clrText = pItem->clrText;
if( iState & CDIS_SELECTED ) clrText = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
dc.SetTextColor(clrText);
CFont font;
HFONT hOldFont = NULL;
if( pItem->mask & TLVIF_STATE ) {
LOGFONT lf;
::GetObject(m_ctrlTree.GetFont(), sizeof(LOGFONT), &lf);
if( pItem->state & TLVIS_BOLD ) lf.lfWeight += FW_BOLD - FW_NORMAL;
if( pItem->state & TLVIS_ITALIC ) lf.lfItalic = TRUE;
if( pItem->state & TLVIS_UNDERLINE ) lf.lfUnderline = TRUE;
if( pItem->state & TLVIS_STRIKEOUT ) lf.lfStrikeOut = TRUE;
font.CreateFontIndirect(&lf);
ATLASSERT(!font.IsNull());
hOldFont = dc.SelectFont(font);
}
UINT format = pItem->mask & TLVIF_FORMAT ? pItem->format : 0;
if (0 == i)
{
CNBDevice* pDevice = (CNBDevice*) m_ctrlTree.GetItemData(hItem);
if (NULL != pDevice && pDevice->GetIDString(_T('*')).GetLength() > 0)
{
CString strBottom = pDevice->GetIDString(m_chHidden);
CRect rcTop = rc; rcTop.DeflateRect(0, 0, 0, rcTop.Height() / 2);
CRect rcBottom = rc; rcBottom.top = rcTop.bottom;
dc.FillSolidRect(&rc, lptvcd->clrTextBk);
LOGFONT lf;
CFontHandle fontHandle = dc.GetCurrentFont();
fontHandle.GetLogFont(&lf);
lf.lfWeight = FW_BOLD;
CFont font;
font.CreateFontIndirect(&lf);
ATLASSERT(!font.IsNull());
HFONT hOldFont = dc.SelectFont(font);
dc.DrawText(pItem->pszText, -1, &rcTop, DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | format);
dc.SelectFont(hOldFont);
COLORREF clrText = dc.GetTextColor();
clrText = RGB(
(GetRValue(clrText) + 0x40) & 0xFF,
(GetGValue(clrText) + 0x40) & 0xFF,
(GetBValue(clrText) + 0x40) & 0xFF);
clrText = dc.SetTextColor(clrText);
dc.DrawText(strBottom, -1, &rcBottom, DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | format);
dc.SetTextColor(clrText);
}
else
{
dc.FillSolidRect(&rc, lptvcd->clrTextBk);
LOGFONT lf;
CFontHandle fontHandle = dc.GetCurrentFont();
fontHandle.GetLogFont(&lf);
lf.lfWeight = FW_BOLD;
CFont font;
font.CreateFontIndirect(&lf);
ATLASSERT(!font.IsNull());
HFONT hOldFont = dc.SelectFont(font);
dc.DrawText(pItem->pszText,
-1,
&rc,
DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | format);
dc.SelectFont(hOldFont);
}
}
else
{
dc.DrawText(pItem->pszText,
-1,
&rc,
DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | format);
}
if( pItem->mask & TLVIF_STATE ) dc.SelectFont(hOldFont);
}
}
// FIX-BY-PATRIA: DrawFocusRect should be done here
if( (iState & CDIS_FOCUS) != 0 && !il.IsNull() ) {
RECT rcFocus = rcItem;
rcFocus.left = 1;
dc.SetTextColor(::GetSysColor(COLOR_BTNTEXT));
dc.DrawFocusRect(&rcFocus);
}
}