本文整理汇总了C++中CDCHandle::DrawIconEx方法的典型用法代码示例。如果您正苦于以下问题:C++ CDCHandle::DrawIconEx方法的具体用法?C++ CDCHandle::DrawIconEx怎么用?C++ CDCHandle::DrawIconEx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDCHandle
的用法示例。
在下文中一共展示了CDCHandle::DrawIconEx方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoDrawItem
//.........这里部分代码省略.........
rcProgress.bottom -= 2;
rcProgress.right = rcProgress.left + int(rcProgress.Width() * percent);
COLORREF color1 = RGB(0xff, 0xf4, 0xcc);
COLORREF color2 = RGB(0xff, 0xde, 0x5c);
COLORREF color3 = RGB(0xff, 0xf4 + (0xde - 0xf4) * percent, 0xcc + (0x5c - 0xcc) * percent);
DrawGradualColorRect(dc, rcProgress, color1, color3, FALSE);
}
//rcDraw.top = rcDraw.bottom;
//rcDraw.bottom += 1;
//dc.FillSolidRect(rcDraw, RGB(0xea, 0xe9, 0xe1));
dc.SetBkMode(TRANSPARENT);
strFilePath = pDir->m_vCacheFiles[idx].strFilePath;
strFile = strFilePath.Right(strFilePath.GetLength() - strFilePath.ReverseFind(_T('\\')) - 1);
strDir = strFilePath.Left(strFilePath.GetLength());
// 绘制文件名
hIconCache = g_IconCache.GetIcon(strFilePath);
if (hIconCache)
{
hIcon = hIconCache;
}
else
{
hIcon = bigfilehelper::GetIconFromFilePath(strFilePath);
}
rcDraw = rcItem;
rcDraw.left = nCurrentEnd;
nCurrentEnd += GetColumnWidth(0);
rcDraw.right = nCurrentEnd;
if (rcDraw.Width() > 8)
{
dc.DrawIconEx(rcDraw.left + 4, rcDraw.top + (rcDraw.Height() - 16) / 2, hIcon, 16, 16);
}
if (rcDraw.Width() > 24)
{
rcDraw.left += 24;
BOOL bFilter = CBigfileFilter::Instance().IsFileInFilter(strFilePath);
BOOL bfilterEnable = GetSysFilterEnable();
if(bFilter && bfilterEnable)
dc.SetTextColor(RGB(0xcc, 0xcc, 0xcc));
dc.DrawText(strFile, strFile.GetLength(), rcDraw, DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_END_ELLIPSIS);
}
// 绘制进度条
rcDraw.left = nCurrentEnd;
nCurrentEnd += GetColumnWidth(1);
rcDraw.right = nCurrentEnd;
if (rcDraw.Width() > 8)
{
CString strSize;
bigfilehelper::GetFileSizeString(pDir->m_vCacheFiles[idx].qwFileSize, strSize);
dc.DrawText(strSize, strSize.GetLength(), rcDraw, DT_LEFT|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS);
}
// if (rcDraw.Width() > 48)
// {
// CPen penBorder;
// CBrush brushProgress;
// CRect rcProgress = rcDraw;
// int nLength;
// rcProgress.left += 40;
// rcProgress.right -= 4;
// rcProgress.top += (rcDraw.Height() - 6) / 2;
// rcProgress.bottom -= (rcDraw.Height() - 6) / 2;
// penBorder.CreatePen(PS_SOLID, 1, RGB(0xb5, 0xb5, 0xb5));
示例2: DoPaint
//draw client area
void WeaselPanel::DoPaint(CDCHandle dc)
{
CRect rc;
GetClientRect(&rc);
if (!m_status.composing)
{
if (m_status.ascii_mode)
dc.DrawIconEx(0, 0, m_iconAlpha, 0, 0);
else
dc.DrawIconEx(0, 0, m_iconEnabled, 0, 0);
return;
}
// background
{
CBrush brush;
brush.CreateSolidBrush(m_style.back_color);
CRgn rgn;
rgn.CreateRectRgnIndirect(&rc);
dc.FillRgn(rgn, brush);
CPen pen;
pen.CreatePen(PS_SOLID | PS_INSIDEFRAME, m_style.border, m_style.border_color);
CPenHandle oldPen = dc.SelectPen(pen);
CBrushHandle oldBrush = dc.SelectBrush(brush);
dc.Rectangle(&rc);
dc.SelectPen(oldPen);
dc.SelectBrush(oldBrush);
}
long height = -MulDiv(m_style.font_point, dc.GetDeviceCaps(LOGPIXELSY), 72);
CFont font;
font.CreateFontW(height, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, m_style.font_face.c_str());
CFontHandle oldFont = dc.SelectFont(font);
dc.SetTextColor(m_style.text_color);
dc.SetBkColor(m_style.back_color);
dc.SetBkMode(TRANSPARENT);
bool drawn = false;
// draw preedit string
if (!m_style.inline_preedit)
drawn |= _DrawPreedit(m_ctx.preedit, dc, m_layout->GetPreeditRect());
/* FIXME: What's this?
// ascii mode icon
if (m_status.ascii_mode && y > rc.top)
{
int icon_x = rc.right - STATUS_ICON_SIZE;
int icon_y = (rc.top + y - m_style.spacing - STATUS_ICON_SIZE) / 2;
dc.DrawIconEx(icon_x, icon_y, m_iconAlpha, 0, 0);
}*/
/* TODO: Deprecated? */
// draw auxiliary string
drawn |= _DrawPreedit(m_ctx.aux, dc, m_layout->GetAuxiliaryRect());
// draw candidates
drawn |= _DrawCandidates(dc);
/* Nothing drawn, hide candidate window */
if (!drawn)
ShowWindow(SW_HIDE);
dc.SelectFont(oldFont);
}
示例3: _DrawNormalItem
void CListViewCtrlEx::_DrawNormalItem( LPDRAWITEMSTRUCT lpdis, const TListItem *pItem )
{
if (!pItem)
return;
int nItem = lpdis->itemID;
CDCHandle dc;
dc.Attach(lpdis->hDC);
HFONT hOldFont = dc.SelectFont(m_fontDef);
BOOL bSelect = FALSE ;
if ((lpdis->itemAction | ODA_SELECT) &&
(lpdis->itemState & ODS_SELECTED))
{
bSelect = TRUE ;
}
if ( bSelect )
dc.FillSolidRect( &lpdis->rcItem, RGB(185,219,255));
else
dc.FillSolidRect( &lpdis->rcItem, pItem->clrBg);
// draw check box
if( pItem->dwFlags&(LISTITEM_CHECKBOX|LISTITEM_RADIOBOX) )
_DrawCheckBox(dc, lpdis->rcItem, _super::GetCheckState(nItem), pItem->dwFlags);
COLORREF oldClr = dc.GetTextColor();
for(int i=0; i<pItem->subItems.size(); ++i)
{
CRect rcSubItem;
DWORD nMarginWidth = 0;
CRect rcBounds;
GetSubItemRect(nItem, i, LVIR_LABEL, &rcSubItem);
nMarginWidth = LEFT_MARGIN_TEXT_COLUMN+3;
if(i==0)
{
if( pItem->dwFlags&(LISTITEM_CHECKBOX|LISTITEM_RADIOBOX) )
{
nMarginWidth+=rcSubItem.left;
}
else
{
rcSubItem.left -= 19;
nMarginWidth+=5;
}
}
#define DT_FLAGS_DRAW_TEXT (DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_END_ELLIPSIS|DT_VCENTER)
rcSubItem.left += LEFT_MARGIN_TEXT_COLUMN;
rcSubItem.right -= 3;
const TListSubItem &subItem = pItem->subItems[i];
if(subItem.type == SUBITEM_LINK)
{
dc.SelectFont(m_fontLink);
dc.SetTextColor(COLOR_LIST_LINK);
CRect rcProbeItem;
dc.DrawText( subItem.str, -1, &rcProbeItem, DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_VCENTER|DT_CALCRECT);
dc.DrawText( subItem.str, -1, &rcSubItem, DT_FLAGS_DRAW_TEXT);
DWORD nMaxWidth = rcProbeItem.Width()+nMarginWidth;
_SetColumnNeedWidth(i,nMaxWidth);
}
else
{
if (subItem.type == SUBITEM_ICON && subItem.nImg != NULL)
{
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();
//.........这里部分代码省略.........