本文整理汇总了C++中CDCHandle::Detach方法的典型用法代码示例。如果您正苦于以下问题:C++ CDCHandle::Detach方法的具体用法?C++ CDCHandle::Detach怎么用?C++ CDCHandle::Detach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDCHandle
的用法示例。
在下文中一共展示了CDCHandle::Detach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _DrawNormalItem
//.........这里部分代码省略.........
dc.DrawIconEx( rcSubItem.left, rcSubItem.top + 3, (HICON)subItem.nImg, 16 , 16, 0, 0, DI_NORMAL );
rcSubItem.left = rcSubItem.left + 18;
}
else if (subItem.type == SUBITEM_PNG)
{
Gdiplus::Image* pImg = BkPngPool::Get(subItem.nImg);
if (pImg)
{
Gdiplus::Graphics graphics(dc);
SIZE size = {0, 0};
if (pImg)
{
size.cx = pImg->GetWidth();
size.cy = pImg->GetHeight();
}
graphics.DrawImage(pImg, Gdiplus::Rect(rcSubItem.left, rcSubItem.top + 5, size.cx, size.cy));
}
rcSubItem.left = rcSubItem.left + 18;
} else if(subItem.type==SUBITEM_COMBO)
{
CDC dcTmp;
dcTmp.CreateCompatibleDC(dc);
HBITMAP hBmpOld = dcTmp.SelectBitmap(m_bitmapCombo);
dc.BitBlt(rcSubItem.right-20, rcSubItem.top + 3, 20, 20, dcTmp, 0, 0, SRCCOPY);
dcTmp.SelectBitmap(hBmpOld);
dcTmp.DeleteDC();
}
UINT uFormat = DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_PATH_ELLIPSIS|DT_VCENTER;
if (i == 3)
{
if (pItem->nLevel == enumLevelRisk)
{
rcSubItem.DeflateRect(2, 3);
CPen penBorder;
penBorder.CreatePen( PS_SOLID, 1, RGB(224, 0, 0) );
CBrush bshInterior;
bshInterior.CreateSolidBrush( RGB(224, 0, 0) );
HPEN hOldPen = dc.SelectPen( penBorder );
HBRUSH hOldBrush = dc.SelectBrush( bshInterior );
dc.RoundRect( rcSubItem, CPoint( 3, 3 ) );
dc.SelectPen(hOldPen);
dc.SelectBrush(hOldBrush);
dc.SetTextColor( RGB(255, 255, 255) );
}
else if (pItem->nLevel == enumLevelUnknown)
{
rcSubItem.DeflateRect(2, 3);
CPen penBorder;
penBorder.CreatePen( PS_SOLID, 1, RGB(250, 115, 5) );
CBrush bshInterior;
bshInterior.CreateSolidBrush( RGB(250, 115, 5) );
HPEN hOldPen = dc.SelectPen( penBorder );
HBRUSH hOldBrush = dc.SelectBrush( bshInterior );
dc.RoundRect( rcSubItem, CPoint( 3, 3 ) );
dc.SelectPen(hOldPen);
dc.SelectBrush(hOldBrush);
dc.SetTextColor( RGB(255, 255, 255) );
}
else
dc.SetTextColor( subItem.clr );
uFormat = DT_SINGLELINE|DT_CENTER|DT_NOPREFIX|DT_PATH_ELLIPSIS|DT_VCENTER;
}
else
dc.SetTextColor( subItem.clr );
dc.DrawText( subItem.str, -1, &rcSubItem, uFormat);
if (subItem.type == SUBITEM_ICON || subItem.type == SUBITEM_PNG)
rcSubItem.left = rcSubItem.left - 18;
CRect rcProbeItem;
dc.DrawText( subItem.str, -1, &rcProbeItem, DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_VCENTER|DT_CALCRECT);
DWORD nMaxWidth = rcProbeItem.Width()+nMarginWidth;
_SetColumnNeedWidth(i,nMaxWidth);
}
}
CPen penx;
penx.CreatePen(PS_SOLID,1,pItem->clrBtmGapLine);
HPEN penOld = dc.SelectPen(penx);
dc.MoveTo( lpdis->rcItem.left, lpdis->rcItem.bottom-1 );
CRect rcClient;
GetClientRect(rcClient);
dc.LineTo( lpdis->rcItem.left + rcClient.Width(), lpdis->rcItem.bottom-1);
dc.SelectPen(penOld);
dc.SelectFont(hOldFont);
dc.SetTextColor(oldClr);
dc.Detach();
}
示例2: _DrawTitleItem
//.........这里部分代码省略.........
CDCHandle dc;
dc.Attach(lpdis->hDC);
dc.FillSolidRect( &lpdis->rcItem, pItem->clrBg);
HFONT hOldFont = dc.SelectFont(m_fontDef);
COLORREF clrOld = dc.GetTextColor();
COLORREF clrDef = clrOld;
//
RECT rcItem = lpdis->rcItem;
if( pItem->dwFlags&LISTITEM_EXPANDABLE )
{
//3 + 9 + 3
if(rcItem.left>-12)
{
CDC dcTmp;
dcTmp.CreateCompatibleDC(dc);
HBITMAP hBmpOld = dcTmp.SelectBitmap(m_bitmapExpand);
RECT rcMinus = _GetRectMinus(rcItem);
dc.BitBlt( rcMinus.left, rcMinus.top, 9, 9, dcTmp, pItem->_isclapsed? 9:0, 0, SRCCOPY);
dcTmp.SelectBitmap(hBmpOld);
}
}
for ( int i = 0; i < pItem->subItems.size(); i++)
{
bool bVCenter=TRUE;
const TListSubItem& subItem = pItem->subItems[i];
CRect rcItem = subItem.rcOffset;
if ( i == 0 )
{
rcItem = lpdis->rcItem;
if(pItem->nTopMargin>=0)
{
rcItem.top += pItem->nTopMargin;
rcItem.bottom -= 0;
bVCenter=FALSE;
}
else
{
rcItem.top += 2;
rcItem.bottom -= 2;
}
rcItem.left+= pItem->nLeftmargin;
}
else
{
if ( rcItem.left < 0 )
{
rcItem.left = nWinWidth+rcItem.left;
}
if (rcItem.right < 0)
{
rcItem.right = nWinWidth+rcItem.right;
}
rcItem.OffsetRect( lpdis->rcItem.left, lpdis->rcItem.top);
}
if ( subItem.type == SUBITEM_TEXT )
{
dc.SetTextColor( subItem.clr);
dc.SelectFont(m_fontDef);
}
else if ( subItem.type == SUBITEM_LINK )
{
dc.SelectFont(m_fontLink);
dc.SetTextColor(COLOR_LIST_LINK);
}
else
{
dc.SetTextColor( subItem.clr);
dc.SelectFont(m_fontDef);
}
CString strTitle = subItem.str;
DWORD nFlag=DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_END_ELLIPSIS;
if(bVCenter)
nFlag|=DT_VCENTER;
if (i==0&&pItem->bBold||pItem->nHeightAdd!=0)
{
HFONT fntOld=dc.SelectFont(BkFontPool::GetFont(pItem->bBold,FALSE,FALSE,pItem->nHeightAdd));
dc.DrawText( strTitle, -1, &rcItem, nFlag);
dc.SelectFont(fntOld);
}
else
dc.DrawText( strTitle, -1, &rcItem, nFlag);
}
CPen pex;
pex.CreatePen(PS_SOLID,1,pItem->clrBtmGapLine);
HPEN penOld = dc.SelectPen(pex);
dc.MoveTo( lpdis->rcItem.left, lpdis->rcItem.bottom-1 );
dc.LineTo( lpdis->rcItem.right, lpdis->rcItem.bottom-1 );
dc.SetTextColor(clrOld);
dc.SelectPen(penOld);
dc.SelectFont(hOldFont);
dc.Detach();
}