本文整理汇总了C++中CFont::IsNull方法的典型用法代码示例。如果您正苦于以下问题:C++ CFont::IsNull方法的具体用法?C++ CFont::IsNull怎么用?C++ CFont::IsNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFont
的用法示例。
在下文中一共展示了CFont::IsNull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UtilGetShellFont
CFont& UtilGetShellFont()
{
static CFont s_shellfont;
if (s_shellfont.IsNull())
{
HFONT hGuiFont = static_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT));
LOGFONT lfGuiFont = { 0 };
if (::GetObject(hGuiFont, sizeof(LOGFONT), &lfGuiFont) == sizeof(LOGFONT))
{
_tcsncpy(lfGuiFont.lfFaceName, _T("MS Shell Dlg 2"), sizeof(lfGuiFont.lfFaceName) / sizeof(TCHAR));
lfGuiFont.lfFaceName[(sizeof(lfGuiFont.lfFaceName) / sizeof(TCHAR)) - 1] = '\0';
s_shellfont.CreateFontIndirect(&lfGuiFont);
}
}
return s_shellfont;
}
示例2: if
void
CNBTreeListView::DrawTreeItem(LPNMTVCUSTOMDRAW lptvcd, UINT iState, const RECT& rcItem)
{
CDCHandle dc = lptvcd->nmcd.hdc;
HTREEITEM hItem = (HTREEITEM) lptvcd->nmcd.dwItemSpec;
tMapItem* pVal = m_mapItems.Lookup(hItem);
if( pVal == NULL ) return;
// NOTE: Having an ImageList attached to the TreeView control seems
// to produce some extra WM_ERASEBKGND msgs, which we can use to
// optimize the painting...
CImageList il = m_ctrlTree.GetImageList(TVSIL_NORMAL);
// If the item had focus then draw it
// NOTE: Only when images are used (see note above)
// FIX-BY-PATRIA: DrawFocusRect should be done later
//if( (iState & CDIS_FOCUS) != 0 && !il.IsNull() ) {
// RECT rcFocus = rcItem;
// rcFocus.left = 1;
// dc.SetTextColor(::GetSysColor(COLOR_BTNTEXT));
// dc.DrawFocusRect(&rcFocus);
//}
// If it's selected, paint the selection background
if( iState & CDIS_SELECTED && iState & CDIS_FOCUS) {
RECT rcHigh = rcItem;
dc.FillSolidRect(&rcHigh, ::GetSysColor(COLOR_HIGHLIGHT));
}
else if( il.IsNull() ) {
RECT rcHigh = rcItem;
dc.FillSolidRect(&rcHigh, lptvcd->clrTextBk);
}
// Always write text with background
dc.SetBkMode(OPAQUE);
dc.SetBkColor(::GetSysColor((iState & CDIS_SELECTED) != 0 ? COLOR_HIGHLIGHT : COLOR_WINDOW));
// Draw all columns of the item
RECT rc = rcItem;
int cnt = pVal->GetSize();
for( int i = 0; i < cnt; i++ ) {
LPTLVITEM pItem = (*pVal)[i];
ATLASSERT(pItem);
if( i != 0 ) rc.left = m_rcColumns[i].left;
rc.right = m_rcColumns[i].right;
if( pItem->mask & TLVIF_IMAGE ) {
ATLASSERT(!il.IsNull());
int cx, cy;
il.GetIconSize(cx, cy);
il.DrawEx(
pItem->iImage,
dc,
rc.left, rc.top,
MIN(cx, rc.right - rc.left), cy,
CLR_NONE, CLR_NONE,
ILD_TRANSPARENT);
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;
//.........这里部分代码省略.........