本文整理汇总了C++中CDCHandle::DrawText方法的典型用法代码示例。如果您正苦于以下问题:C++ CDCHandle::DrawText方法的具体用法?C++ CDCHandle::DrawText怎么用?C++ CDCHandle::DrawText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDCHandle
的用法示例。
在下文中一共展示了CDCHandle::DrawText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRect
RECT CItemData::GetRect(CDCHandle& dc)
{
if ( NULL == m_pData )
return RECT() ;
if ( TIT_LINK != m_pData->dwType && TIT_TEXT != m_pData->dwType )
return RECT() ;
RECT rcItem = {0} ;
wstring wsText ;
switch(m_pData->dwType)
{
case TIT_LINK:
{
CFont font ;
font.CreateFont(13,0,0,0,GetBold()?FW_BOLD:FW_NORMAL,0,TRUE,0,0,0,0,0,0,_T("Tahoma")) ;
HFONT hOldFont = dc.SelectFont(font) ;
wsText = m_pData->pData->pilLink->wsText ;
dc.DrawText(wsText.c_str() , wsText.size() , &rcItem , DT_CALCRECT|DT_NOPREFIX|DT_NOCLIP|DT_SINGLELINE) ;
dc.SelectFont(hOldFont) ;
}
break;
case TIT_TEXT :
wsText = m_pData->pData->pitText->wsText ;
dc.DrawText(wsText.c_str() , wsText.size() , &rcItem , DT_CALCRECT|DT_NOPREFIX|DT_NOCLIP|DT_SINGLELINE) ;
break ;
}
return rcItem ;
}
示例2: DrawMenuItemText
void CMenuSkin::DrawMenuItemText(CDCHandle dc, UINT uMenuRes, WORD wMenuID, const CString &lpszMenuString, const RECT &rect, CBitmapHandle hBitmap, CBitmapHandle hBitmapMask, bool bEnabled, bool bBold)
{
if (hBitmap == (HBITMAP)-1 || hBitmap == (HBITMAP)-2)
{
int iWidth = m_imgMenuIcon.GetWidth() / 2;
int iBegin = iWidth * (-(int)(HBITMAP)hBitmap - 1);
int iY = (rect.bottom - rect.top - ICON_WIDTH) / 2;
RECT rcDest = { rect.left + iY + 1, rect.top + iY, rect.left + iY + iWidth + 1, rect.top + iY + iWidth };
RECT rcSrc = { iBegin, 0, iBegin + iWidth, m_imgMenuIcon.GetHeight() };
m_imgMenuIcon.Draw(dc, rcDest, rcSrc);
}
else if ( (hBitmap && ::GetObjectType(hBitmap) == OBJ_BITMAP) ||
(hBitmapMask && ::GetObjectType(hBitmapMask) == OBJ_BITMAP) )
{
ICONINFO ii = { TRUE, 8, 8, hBitmapMask, hBitmap };
CIcon ico;
ico.CreateIconIndirect(&ii);
int iY = (rect.bottom - rect.top - ICON_WIDTH) / 2;
ico.DrawIconEx(dc, rect.left + iY + 1, rect.top + iY, ICON_WIDTH, ICON_WIDTH);
}
CString strMenuText = lpszMenuString;
int n = strMenuText.Find('\n');
if (n >= 0)
strMenuText = strMenuText.Mid(0, n);
TCHAR szAcc[128] = { 0 };
n = strMenuText.Find('\t');
if (n >= 0)
{
_tcscpy_s(szAcc, strMenuText.Mid(n + 1));
strMenuText = strMenuText.Mid(0, n);
}
RECT rcText = rect;
rcText.left += ICON_WIDTH + 6;
rcText.right -= 5;
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(CSkinProperty::GetColor(bEnabled ? Skin_Property_Menu_Text_Color : Skin_Property_Menu_Disabled_Text_Color));
dc.SelectFont(bBold ? s()->Common()->GetBoldFont() : s()->Common()->GetDefaultFont());
dc.DrawText(strMenuText, strMenuText.GetLength(), &rcText, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
if (szAcc[0])
{
dc.SetTextColor(CSkinProperty::GetColor(Skin_Property_Menu_Shortcut_Text_Color));
dc.SelectFont(s()->Common()->GetMenuAccFont());
dc.DrawText(szAcc, -1, &rcText, DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
}
}
示例3: DrawButtons
void CDxMonthPicker::DrawButtons(CDCHandle dc)
{
if (m_btnToday->m_bVisible)
{
dc.FillSolidRect(m_btnToday->m_rcButton, GetSysColor(COLOR_BTNFACE));
CRect rcButtonX = m_btnToday->m_rcButton;
rcButtonX.DeflateRect(1, 1, 1, 1);
if (m_btnToday->m_bPressed)
{
dc.Draw3dRect(m_btnToday->m_rcButton, GetSysColor(COLOR_BTNTEXT), GetSysColor(COLOR_BTNFACE));
dc.Draw3dRect(rcButtonX, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
}
else
{
dc.Draw3dRect(m_btnToday->m_rcButton, GetSysColor(COLOR_BTNFACE), GetSysColor(COLOR_BTNTEXT));
dc.Draw3dRect(rcButtonX, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DSHADOW));
}
HFONT hFontOld = (HFONT)dc.SelectFont(CDxFontManager::GetSingleton().GetFont(DUIF_DEFAULTFONT));
CString strCaption = _T("Today");
dc.SetTextColor(RGB(0,0,0));
dc.DrawText(strCaption, strCaption.GetLength(), rcButtonX, DT_VCENTER | DT_CENTER | DT_SINGLELINE);
}
}
示例4: RanderText
bool CTooltipText::RanderText(CDCHandle& dc , RECT rcRect , int iRowSpace)
{
int iHeight = x_GetLineHeight(dc) ;
CRect rc (rcRect.left,rcRect.top,rcRect.left,rcRect.top+iHeight) ;
CRect rcLine (rcRect.left,rcRect.top,rcRect.left,rcRect.top+iHeight) ;
list<CItemData>::iterator it = m_ItemList.begin() ;
m_LinkBlockList.clear() ;
for ( ;it!=m_ItemList.end() ; it++ )
{
if(TIT_RETURN == it->GetType() )
{
rc.bottom += iHeight ;
rcLine.OffsetRect(CPoint(0,iHeight+iRowSpace)) ;
rcLine.right = rcRect.left ;
}
else if ( TIT_LINK == it->GetType() || TIT_TEXT == it->GetType() )
{
CRect rcItem = it->GetRect(dc) ;
rcLine.left = rcLine.right ;
rcLine.right += rcItem.right ;
rcLine.right = rcLine.right>rcRect.right ? rcRect.right : rcLine.right;
COLORREF clrOld = dc.GetTextColor() ;
dc.SetTextColor(it->GetColor()) ;
if ( it->GetType() == TIT_LINK )
{
CFont font ;
font.CreateFont(13,0,0,0,it->GetBold()?FW_BOLD:FW_NORMAL,0,TRUE,0,0,0,0,0,0,_T("Tahoma")) ;
HFONT hOldFont = dc.SelectFont(font) ;
LINKBLOCK lb = {it->GetColor(),it->GetColorHover(),it->GetColorActive(),it->GetBold(),rcLine,it->GetId(),it->GetText()};
m_LinkBlockList.push_back(lb);
dc.DrawText(it->GetText().c_str() , it->GetText().size() , &rcLine , DT_NOCLIP|DT_NOPREFIX |DT_SINGLELINE|DT_WORD_ELLIPSIS) ;
dc.SelectFont(hOldFont) ;
}
else
dc.DrawText(it->GetText().c_str() , it->GetText().size() , &rcLine , DT_NOCLIP|DT_NOPREFIX |DT_SINGLELINE|DT_WORD_ELLIPSIS) ;
dc.SetTextColor(clrOld) ;
}
}
return true ;
}
示例5: DrawMonthHeader
void CDxDatePickerMonth::DrawMonthHeader(CDCHandle dc)
{
if (m_rcHeader.IsRectEmpty())
return;
COleDateTime dtMonth = GetMonth();
CRect rcHeader = m_rcHeader;
CRect rcLeftScroll = m_rcLeftScroll;
CRect rcRightScroll = m_rcRightScroll;
CRect rcClient(m_pControl->m_rcControl);
//dc.Draw3dRect(0, 0, rcClient.Width(), rcClient.Height(), m_clrStaticBorder, m_clrStaticBorder);
CRect rcHeaderBk = m_rcMonth;
rcHeaderBk.bottom = rcHeader.bottom;
// fill background
dc.FillSolidRect(rcHeaderBk, RGB(191, 219, 255));
// draw header text
dc.SetBkColor(GetSysColor(COLOR_BTNFACE));
dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
HFONT hFontOld = (HFONT)dc.SelectFont(CDxFontManager::GetSingleton().GetFont(DUIF_DEFAULTFONT));
CString strText;
if (!m_pControl->m_strYearMonthFormat.IsEmpty())
{
//strText = GetDateFormat(dtMonth, pControl->m_strYearMonthFormat);
}
else
{
strText.Format(_T("%s %d"), (LPCTSTR)m_pControl->GetMonthName( dtMonth.GetMonth()), dtMonth.GetYear());
}
dc.DrawText(strText, strText.GetLength(), &rcHeader, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
// draw left scroll triangle
if (!rcLeftScroll.IsRectEmpty())
{
// draw left triangle itself
if (GetShowLeftScroll())
DrawScrollTriangle(dc, rcLeftScroll, TRUE, m_clrMonthHeaderButton, m_pControl->m_bYearsTriangle);
}
// draw right scroll triangle
if (!rcRightScroll.IsRectEmpty())
{
// draw right triangle itself
if (GetShowRightScroll())
DrawScrollTriangle(dc, rcRightScroll, FALSE, m_clrMonthHeaderButton, m_pControl->m_bYearsTriangle);
}
dc.SelectFont(hFontOld);
}
示例6:
void CToolBarPropertyPage::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if (lpDrawItemStruct->CtlID == IDC_LIST_ICON) {
CDCHandle dc = lpDrawItemStruct->hDC;
// Save these value to restore them when done drawing.
COLORREF crOldTextColor = dc.GetTextColor();
COLORREF crOldBkColor = dc.GetBkColor();
// If this item is selected, set the background color
// and the text color to appropriate values. Also, erase
// rect by filling it with the background color.
if ((lpDrawItemStruct->itemAction | ODA_SELECT) &&
(lpDrawItemStruct->itemState & ODS_SELECTED))
{
dc.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
dc.SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
dc.FillSolidRect(&lpDrawItemStruct->rcItem,
::GetSysColor(COLOR_HIGHLIGHT));
} else
dc.FillSolidRect(&lpDrawItemStruct->rcItem, crOldBkColor);
#if 0
// If this item has the focus, draw a red frame around the
// item's rect.
if ((lpDrawItemStruct->itemAction | ODA_FOCUS) &&
(lpDrawItemStruct->itemState & ODS_FOCUS))
{
CBrush br;
br.CreateSolidBrush(RGB(255, 0, 0));
dc.FrameRect(&lpDrawItemStruct->rcItem, br);
}
#endif
IconListData* pData = (IconListData*)lpDrawItemStruct->itemData;
if (pData) {
CIconHandle icon = m_imgList.GetIcon(pData->nIndex);
if (icon.m_hIcon)
icon.DrawIconEx(dc, lpDrawItemStruct->rcItem.left + cxMargin, lpDrawItemStruct->rcItem.top + cyMargin, m_iconSize.cx, m_iconSize.cy);
lpDrawItemStruct->rcItem.left += m_iconSize.cx + cxMargin + IconTextMargin;
// Draw the text.
dc.DrawText(
pData->strText,
pData->strText.GetLength(),
&lpDrawItemStruct->rcItem,
DT_SINGLELINE | DT_VCENTER);
}
// Reset the background color and the text color back to their
// original values.
dc.SetTextColor(crOldTextColor);
dc.SetBkColor(crOldBkColor);
}
}
示例7: 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);
}
示例8: DrawItem
void CDuiMenuODWnd::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
CRect rcItem=lpDrawItemStruct->rcItem;
DuiMenuItemData *pdmmi=(DuiMenuItemData*)lpDrawItemStruct->itemData;
CDCHandle dc(lpDrawItemStruct->hDC);
CDCHandle dcMem;
dcMem.CreateCompatibleDC(dc);
CBitmap bmp=CGdiAlpha::CreateBitmap32(dc,rcItem.Width(),rcItem.Height());
CBitmapHandle hOldBmp=dcMem.SelectBitmap(bmp);
dcMem.BitBlt(0,0,rcItem.Width(),rcItem.Height(),dc,rcItem.left,rcItem.top,SRCCOPY);
rcItem.MoveToXY(0,0);
if(pdmmi)
{
MENUITEMINFO mii= {sizeof(MENUITEMINFO),MIIM_FTYPE,0};
HMENU menuPopup=pdmmi->hMenu;
GetMenuItemInfo(menuPopup,pdmmi->nID,FALSE,&mii);
BOOL bDisabled = lpDrawItemStruct->itemState & ODS_GRAYED;
BOOL bSelected = lpDrawItemStruct->itemState & ODS_SELECTED;
BOOL bChecked = lpDrawItemStruct->itemState & ODS_CHECKED;
BOOL bRadio = mii.fType&MFT_RADIOCHECK;
m_pItemSkin->Draw(dcMem,rcItem,bSelected?1:0); //draw back
//draw icon
CRect rcIcon;
rcIcon.left=rcItem.left+m_nIconMargin;
rcIcon.right=rcIcon.left+m_szIcon.cx;
rcIcon.top=rcItem.top+(rcItem.Height()-m_szIcon.cy)/2;
rcIcon.bottom=rcIcon.top+m_szIcon.cy;
if(bChecked)
{
if(m_pCheckSkin)
{
if(bRadio) m_pCheckSkin->Draw(dcMem,rcIcon,1);
else m_pCheckSkin->Draw(dcMem,rcIcon,0);
}
}
else if(pdmmi->itemInfo.iIcon!=-1 && m_pIconSkin)
{
m_pIconSkin->Draw(dcMem,rcIcon,pdmmi->itemInfo.iIcon);
}
rcItem.left=rcIcon.right+m_nIconMargin;
//draw text
CRect rcTxt=rcItem;
rcTxt.DeflateRect(m_nTextMargin,0);
dcMem.SetBkMode(TRANSPARENT);
COLORREF crOld=dcMem.SetTextColor(bDisabled?m_crTxtGray:(bSelected?m_crTxtSel:m_crTxtNormal));
HFONT hOldFont=0;
hOldFont=dcMem.SelectFont(m_hFont);
dcMem.DrawText(pdmmi->itemInfo.strText,pdmmi->itemInfo.strText.GetLength(),&rcTxt,DT_SINGLELINE|DT_VCENTER|DT_LEFT);
dcMem.SelectFont(hOldFont);
dcMem.SetTextColor(crOld);
if(bSelected && m_pItemSkin->GetStates()>2)
{
//draw select mask
CRect rcItem=lpDrawItemStruct->rcItem;
rcItem.MoveToXY(0,0);
m_pItemSkin->Draw(dcMem,rcItem,2);
}
}
else //if(strcmp("sep",pXmlItem->Value())==0)
{
m_pItemSkin->Draw(dcMem,rcItem,0); //draw back
if(m_pIconSkin)
{
rcItem.left += m_pIconSkin->GetSkinSize().cx+m_nIconMargin*2;
}
if(m_pSepSkin)
m_pSepSkin->Draw(dcMem,&rcItem,0);
else
{
CGdiAlpha::DrawLine(dcMem, rcItem.left, rcItem.top, rcItem.right, rcItem.top, RGB(196,196,196), PS_SOLID);
CGdiAlpha::DrawLine(dcMem, rcItem.left, rcItem.top+1, rcItem.right, rcItem.top+1, RGB(255,255,255), PS_SOLID);
}
}
rcItem=lpDrawItemStruct->rcItem;
dc.BitBlt(rcItem.left,rcItem.top,rcItem.Width(),rcItem.Height(),dcMem,0,0,SRCCOPY);
dcMem.SelectBitmap(hOldBmp);
dcMem.DeleteDC();
bmp.DeleteObject();
}
示例9: 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);
}
}
示例10: DoDrawItem
void CBigFileListCtrl::DoDrawItem(CDCHandle dc, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CRect rcItem = lpDrawItemStruct->rcItem;
size_t idx = (size_t)lpDrawItemStruct->itemData;
int nItem = lpDrawItemStruct->itemID;
BOOL bSelect = lpDrawItemStruct->itemState & ODS_SELECTED;
CRect rcDraw;
CVirtualDirManager* pDir = (CVirtualDirManager*)m_pOwner;
CString strFilePath, strFile, strDir;
HICON hIcon = NULL, hIconCache = NULL;
int nCurrentEnd = rcItem.left;
double percent;
CRect rcClient;
CFontHandle underlineFont = KuiFontPool::GetFont(FALSE, TRUE, FALSE);
CFontHandle normalFont = KuiFontPool::GetFont(FALSE, FALSE, FALSE);
// 绘制背景
{
rcDraw = rcItem;
GetClientRect(rcClient);
if (rcClient.right > rcDraw.right)
rcDraw.right = rcClient.right;
dc.FillSolidRect(rcDraw, RGB(0xff,0xff,0xff));
}
if (idx == -1)
{
CString strMore;
dc.SelectFont(underlineFont);
dc.SetTextColor(RGB(0x4d, 0x70, 0x96));
strMore.Format(
//_T("已经显示了%d个文件,还有%d个没有显示,点击此处查看全部"),
_T("还有%d个没有显示,点击此处查看全部"),
//GetItemCount() - 1,
m_dwMoreItems);
rcDraw = rcItem;
dc.FillSolidRect(rcDraw, RGB(0xff, 0xff, 0xff));
int nLeft = rcItem.left + GetColumnWidth(0) + GetColumnWidth(1);
int nRight = nLeft + GetColumnWidth(2);
rcDraw.left = nLeft;
rcDraw.right = nRight;
dc.DrawText(strMore, strMore.GetLength(), rcDraw, DT_LEFT|DT_BOTTOM|DT_SINGLELINE|DT_CALCRECT);
if (rcDraw.right > nRight)
rcDraw.right = nRight;
dc.DrawText(strMore, strMore.GetLength(), rcDraw, DT_LEFT|DT_BOTTOM|DT_SINGLELINE|DT_END_ELLIPSIS);
m_rcMore.left = rcDraw.left;
m_rcMore.right = rcDraw.right;
m_rcMore.top = 0;
m_rcMore.bottom = m_nItemHeight;
return;
}
if (idx == -2)
{
CString strNone;
dc.SelectFont(normalFont);
dc.SetTextColor(RGB(0, 0, 0));
strNone = _T("没有发现文件,您可以重新扫描。");
rcDraw = rcItem;
dc.FillSolidRect(rcDraw, RGB(0xff, 0xff, 0xff));
rcDraw.left = rcItem.left + GetColumnWidth(0) + GetColumnWidth(1);
rcDraw.right = rcDraw.left + GetColumnWidth(2);
dc.DrawText(strNone, strNone.GetLength(), rcDraw, DT_LEFT|DT_BOTTOM|DT_SINGLELINE|DT_END_ELLIPSIS);
return;
}
percent = (double)pDir->m_vCacheFiles[idx].qwFileSize / pDir->m_vCacheFiles[0].qwFileSize;
rcDraw = rcItem;
dc.SetTextColor(RGB(0,0,0));
if (bSelect)
{
CPen penBorder;
CBrush brushBk;
CRect rcSelect = rcDraw;
penBorder.CreatePen(PS_SOLID, 1, RGB(0x7d, 0xa2, 0xce));
brushBk.CreateSolidBrush(RGB(0xeb, 0xf4, 0xfd));
dc.SelectPen(penBorder);
dc.SelectBrush(brushBk);
dc.RoundRect(rcSelect, CPoint(3, 3));
rcSelect.left += 2;
rcSelect.right -= 2;
rcSelect.top += 2;
rcSelect.bottom -= 2;
DrawGradualColorRect(dc, rcSelect, RGB(0xdd, 0xec, 0xfd), RGB(0xc2, 0xdc, 0xfd));
}
else
{
dc.FillSolidRect(rcDraw, RGB(0xff, 0xff, 0xff));
}
{
// 画背景进度条
CRect rcProgress = rcDraw;
rcProgress.left += 2;
rcProgress.right -= 2;
rcProgress.top += 2;
rcProgress.bottom -= 2;
rcProgress.right = rcProgress.left + int(rcProgress.Width() * percent);
COLORREF color1 = RGB(0xff, 0xf4, 0xcc);
COLORREF color2 = RGB(0xff, 0xde, 0x5c);
//.........这里部分代码省略.........
示例11: DrawItem
//.........这里部分代码省略.........
pDC.Draw3dRect(itemRect, ::GetSysColor(COLOR_BTNHILIGHT), ::GetSysColor(COLOR_BTNSHADOW));
}
}
else
{
// Draw top-left borders
// White line
pOldPen = pDC.SelectPen(penBtnHiLight);
pDC.MoveTo(itemRect.left, itemRect.bottom-1);
pDC.LineTo(itemRect.left, itemRect.top);
pDC.LineTo(itemRect.right, itemRect.top);
// Light gray line
pDC.SelectPen(pen3DLight);
pDC.MoveTo(itemRect.left+1, itemRect.bottom-1);
pDC.LineTo(itemRect.left+1, itemRect.top+1);
pDC.LineTo(itemRect.right, itemRect.top+1);
// Draw bottom-right borders
// Black line
pDC.SelectPen(pen3DDKShadow);
pDC.MoveTo(itemRect.left, itemRect.bottom-1);
pDC.LineTo(itemRect.right-1, itemRect.bottom-1);
pDC.LineTo(itemRect.right-1, itemRect.top-1);
// Dark gray line
pDC.SelectPen(penBtnShadow);
pDC.MoveTo(itemRect.left+1, itemRect.bottom-2);
pDC.LineTo(itemRect.right-2, itemRect.bottom-2);
pDC.LineTo(itemRect.right-2, itemRect.top);
//
pDC.SelectPen(pOldPen);
}
}
// Read the button's title
CString sTitle;
int nLen = GetWindowTextLength();
int nRetLen = GetWindowText(sTitle.GetBufferSetLength(nLen), nLen + 1);
CRect captionRect = lpDIS->rcItem;
// Draw the icon
if (m_csIcons[0].hIcon != 0)
{
DrawTheIcon(pDC, !sTitle.IsEmpty(), lpDIS->rcItem, captionRect, m_bIsPressed, m_bIsDisabled);
}
if (m_csBitmaps[0].hBitmap != 0)
{
pDC.SetBkColor(RGB(255,255,255));
DrawTheBitmap(pDC, !sTitle.IsEmpty(), lpDIS->rcItem, captionRect, m_bIsPressed, m_bIsDisabled);
}
// Write the button title (if any)
if (!sTitle.IsEmpty())
{
// Draw the button's title
// If button is pressed then "press" title also
if (m_bIsPressed && !m_bIsCheckBox)
{
captionRect.OffsetRect(1, 1);
}
// Center text
CRect centerRect = captionRect;
pDC.DrawText(sTitle, -1, captionRect, DT_WORDBREAK | DT_CENTER | DT_CALCRECT);
captionRect.OffsetRect((centerRect.Width() - captionRect.Width())/2, (centerRect.Height() - captionRect.Height())/2);
pDC.SetBkMode(TRANSPARENT);
if (m_bIsDisabled)
{
captionRect.OffsetRect(1, 1);
pDC.SetTextColor(::GetSysColor(COLOR_3DHILIGHT));
pDC.DrawText(sTitle, -1, captionRect, DT_WORDBREAK | DT_CENTER);
captionRect.OffsetRect(-1, -1);
pDC.SetTextColor(::GetSysColor(COLOR_3DSHADOW));
pDC.DrawText(sTitle, -1, captionRect, DT_WORDBREAK | DT_CENTER);
}
else
{
if (m_bMouseOnButton || m_bIsPressed)
{
pDC.SetTextColor(m_crColors[BTNST_COLOR_FG_IN]);
pDC.SetBkColor(m_crColors[BTNST_COLOR_BK_IN]);
}
else
{
pDC.SetTextColor(m_crColors[BTNST_COLOR_FG_OUT]);
pDC.SetBkColor(m_crColors[BTNST_COLOR_BK_OUT]);
}
pDC.DrawText(sTitle, -1, captionRect, DT_WORDBREAK | DT_CENTER);
}
}
if (!m_bIsFlat || (m_bIsFlat && m_bDrawFlatFocus))
{
// Draw the focus rect
if (m_bIsFocused)
{
CRect focusRect = itemRect;
focusRect.DeflateRect(3, 3);
pDC.DrawFocusRect(&focusRect);
}
}
}
示例12: DrawDay
BOOL CDxDatePickerDay::DrawDay(CDCHandle dc)
{
// check this day item
BOOL bThisMonthItem = FALSE;
BOOL bNextMonthItem = FALSE;
BOOL bPreviousMonthItem = FALSE;
CDxMonthPicker* pControl = GetDatePicker();
CDxDatePickerMonth* pMonth = GetMonth();
COleDateTime dtDay = GetDate();
CRect rcDay = GetRect();
if (dtDay.GetYear() > pMonth->GetMonth().GetYear())
{
bNextMonthItem = TRUE;
}
else if (dtDay.GetYear() < pMonth->GetMonth().GetYear())
{
bPreviousMonthItem = TRUE;
}
else
{
// years the same
if (dtDay.GetMonth() > pMonth->GetMonth().GetMonth())
bNextMonthItem = TRUE;
else if (dtDay.GetMonth() < pMonth->GetMonth().GetMonth())
bPreviousMonthItem = TRUE;
else // months the same
bThisMonthItem = TRUE;
}
if (bPreviousMonthItem && !pMonth->GetShowDaysBefore())
return FALSE;
if (bNextMonthItem && !pMonth->GetShowDaysAfter())
return FALSE;
// apply settings to the DC
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
dc.FillSolidRect(rcDay, GetSysColor(COLOR_WINDOW));
// change default drawing metrics if day is selected
if (pControl->IsSelected(dtDay))
{
dc.SetTextColor(GetSysColor(COLOR_WINDOW));
dc.FillSolidRect(rcDay, GetSysColor(COLOR_WINDOWTEXT));
}
// make a text for drawing
CString strText;
strText.Format(_T("%i"), dtDay.GetDay());
// draw item content
{
// draw item text
HFONT hFontOld = (HFONT)dc.SelectFont(CDxFontManager::GetSingleton().GetFont(DUIF_DEFAULTFONT));
dc.DrawText(strText, strText.GetLength(), &rcDay, DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_NOCLIP);
}
CRect rcFocus = rcDay;
BOOL bToday = FALSE;
// highlight today item
if (IsToday(dtDay))
{
dc.Draw3dRect(rcDay, GetSysColor(COLOR_HIGHLIGHT), GetSysColor(COLOR_HIGHLIGHT));
bToday = TRUE;
}
if (pControl->IsSelected(dtDay))
{
if (!bToday)
{
dc.SetTextColor(0);
dc.SetBkColor(RGB(255, 255, 255));
dc.DrawFocusRect(&rcFocus);
}
else
{
COLORREF clrFocus = GetSysColor(COLOR_HIGHLIGHT);
clrFocus = clrFocus ^ RGB(255, 128, 128);
rcFocus.DeflateRect(0, 0, 1, 1);
CPen pen1;
pen1.CreatePen(PS_DOT, 1, clrFocus);
HPEN hOldPen = dc.SelectPen(pen1);
dc.MoveTo(rcFocus.TopLeft());
dc.LineTo(rcFocus.right, rcFocus.top);
dc.LineTo(rcFocus.right, rcFocus.bottom);
dc.LineTo(rcFocus.left, rcFocus.bottom);
dc.LineTo(rcFocus.left, rcFocus.top);
dc.SelectPen(hOldPen);
}
//.........这里部分代码省略.........
示例13: OnDrawitem
LRESULT CLogListBox::OnDrawitem(UINT uMsg, WPARAM wParam, LPARAM lParam,BOOL& bHandled)
{
LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam;
if(!dis) return FALSE;
LogListBoxItem * item = (LogListBoxItem *)dis->itemData;
if(!item) return FALSE;
CDCHandle dc = dis->hDC;
if(dis->itemAction & (ODA_DRAWENTIRE|ODA_SELECT))
{
dc.SetBkColor(GetSysColor(COLOR_WINDOW));
dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
CRect r(dis->rcItem);
if(!(dis->itemState & ODS_SELECTED ))
{
CBrush br;
br.CreateSolidBrush(GetSysColor(COLOR_WINDOW));
dc.FillRect(r,br);
}
CRect rct;
GetClientRect(&rct);
if(dis->itemState & ODS_SELECTED )
{
CRect rd(dis->rcItem);
GuiTools::FillRectGradient(dis->hDC,rd,0xEAE2D9, 0xD3C1AF, false);
}
else if(dis->itemID != GetCount()-1) // If it isn't last item
{
CPen pen;
pen.CreatePen(PS_SOLID, 1, RGB(190,190,190));
SelectObject(dc.m_hDC, pen);
dc.MoveTo(rct.left, r.bottom-1);
dc.LineTo(rct.right, r.bottom-1);
}
SetBkMode(dc.m_hDC,TRANSPARENT);
SIZE TimeLabelDimensions;
SelectObject(dc.m_hDC, NormalFont);
GetTextExtentPoint32(dc, item->Time, item->Time.GetLength(), &TimeLabelDimensions);
// Writing error time
ExtTextOutW(dc.m_hDC, rct.right-5-TimeLabelDimensions.cx, r.top + LLB_VertMargin, ETO_CLIPPED, r, item->Time, item->Time.GetLength(), 0);
// Writing error title
SelectObject(dc.m_hDC, UnderlineFont);
ExtTextOutW(dc.m_hDC, r.left+56, r.top + LLB_VertMargin, ETO_CLIPPED, r, item->strTitle, wcslen(item->strTitle), 0);
// Writing some info
SelectObject(dc.m_hDC, NormalFont);
RECT ItemRect={r.left+56, r.top + LLB_VertMargin + LLB_VertDivider + item->TitleHeight,
r.right - 10, r.bottom-LLB_VertMargin};
dc.DrawText(item->Info, item->Info.GetLength() , &ItemRect, DT_NOPREFIX);
// Writing error text with bold (explication of error)
SelectObject(dc.m_hDC, BoldFont);
RECT TextRect = {r.left+56, LLB_VertMargin +r.top+ item->TitleHeight+LLB_VertDivider+((item->Info.GetLength())?(item->InfoHeight+LLB_VertDivider):0), r.right - 10, r.bottom-LLB_VertMargin};
dc.DrawText(item->strText, wcslen(item->strText), &TextRect, DT_NOPREFIX);
if(item->Type == logError)
dc.DrawIcon(12,r.top+8,ErrorIcon);
else if(item->Type == logWarning)
dc.DrawIcon(12,r.top+8,WarningIcon);
}
bHandled = true;
return 0;
}
示例14: DrawImage
bool CPrintFolder::DrawImage(CDCHandle dc, CPoint point, IW::Image &image, IW::FolderItem *pItem)
{
HFONT hOldFont = dc.SelectFont(m_font);
UINT uTextStyle = DT_NOPREFIX | DT_EDITCONTROL;
if (m_bCenter) uTextStyle |= DT_CENTER;
if (!m_bWrap) uTextStyle |= DT_WORD_ELLIPSIS; else uTextStyle |= DT_WORDBREAK;
// Calc Text Size
CSimpleArray<CString> arrayStrText;
CSimpleValArray<int> arrayHeights;
pItem->GetFormatText(arrayStrText, m_annotations, true);
int i, nHeightText = 0;
for(i = 0; i < arrayStrText.GetSize(); i++)
{
CRect r(point.x,
point.y + _sizeSection.cy,
point.x + _sizeSection.cx,
point.y + _sizeSection.cy);
dc.DrawText(arrayStrText[i], -1,
&r, uTextStyle | DT_CALCRECT);
int nLimit = _sizeThumbNail.cy / 2;
if (nHeightText + r.Height() > nLimit)
{
arrayHeights.Add(nLimit - nHeightText);
nHeightText = nLimit;
break;
}
else
{
nHeightText += r.Height();
arrayHeights.Add(r.Height());
}
}
CSize sizeThumbNailLocal = _sizeThumbNail;
sizeThumbNailLocal.cy -= nHeightText;
if (!image.IsEmpty())
{
IW::Page page = image.GetFirstPage();
// Best fit rotate
if (m_nPrintRotateBest > 0)
{
bool bRotate = ((sizeThumbNailLocal.cx > sizeThumbNailLocal.cy) &&
(page.GetWidth() < page.GetHeight())) ||
((sizeThumbNailLocal.cx < sizeThumbNailLocal.cy) &&
(page.GetWidth() > page.GetHeight()));
if (bRotate)
{
IW::Image imageRotate;
if (m_nPrintRotateBest == 1)
{
IW::Rotate270(image, imageRotate, _pStatus);
}
else
{
IW::Rotate90(image, imageRotate, _pStatus);
}
image = imageRotate;
}
}
const int nSizeAverage = (page.GetWidth() + page.GetHeight()) / 2;
page = image.GetFirstPage();
page.SetBackGround(m_clrBackGround);
const CRect rectBounding = image.GetBoundingRect();
const int nWidthPels = dc.GetDeviceCaps(HORZRES);
const int nHeightPels = dc.GetDeviceCaps(VERTRES);
const long icx = rectBounding.Width();
const long icy = rectBounding.Height();
const long nDiv = 0x1000;
// Scale the image
long sh = MulDiv(sizeThumbNailLocal.cx, nDiv, icx);
long sw = MulDiv(sizeThumbNailLocal.cy, nDiv, icy);
long s = IW::Min(sh, sw);
const CSize sizeImage(MulDiv(page.GetWidth(), s, nDiv), MulDiv(page.GetHeight(), s, nDiv));
const CPoint pt(point.x + ((sizeThumbNailLocal.cx - sizeImage.cx) / 2) + m_nPadding,
point.y + ((sizeThumbNailLocal.cy - sizeImage.cy) / 2) + m_nPadding);
const CRect rectPrint(pt, sizeImage);
if ((rectPrint.Width() < page.GetWidth()) && (rectPrint.Height() < page.GetHeight()))
{
IW::Image imageScaled;
IW::Scale(image, imageScaled, rectPrint.Size(), _pStatus);
image = imageScaled;
//.........这里部分代码省略.........
示例15: PrintHeaders
bool CPrintFolder::PrintHeaders(CDCHandle dc, UINT nPage)
{
try
{
int nBkMode = dc.SetBkMode(TRANSPARENT);
COLORREF clrTextColor = dc.SetTextColor(RGB(0,0,0));
// Draw header and footer!!
if (m_bShowFooter || m_bShowPageNumbers)
{
HFONT hOldFont = dc.SelectFont(m_font);
int cy = _rectExtents.bottom - (m_nFooterHeight - m_nPadding);
dc.MoveTo(_rectExtents.left + m_nPadding, cy);
dc.LineTo(_rectExtents.right - m_nPadding, cy);
CRect r(_rectExtents.left, cy, _rectExtents.right, _rectExtents.bottom);
if (m_bShowFooter)
{
DWORD dwStyle = DT_NOCLIP | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX;
dwStyle |= (!m_bShowPageNumbers) ? DT_CENTER : DT_LEFT;
dc.DrawText(_strFooter, -1, r, dwStyle);
}
if (m_bShowPageNumbers)
{
DWORD dwStyle = DT_NOCLIP | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX;
dwStyle |= (!m_bShowFooter) ? DT_CENTER : DT_RIGHT;
CString str;
str.Format(IDS_PRINT_PAGE_FMT, nPage + 1, GetPageCount());
dc.DrawText(str, -1, &r, dwStyle);
}
dc.SelectFont(hOldFont);
}
if (m_bShowHeader)
{
int cy = (_rectExtents.top + m_nHeaderHeight) - m_nPadding;
dc.MoveTo(_rectExtents.left + m_nPadding, cy);
dc.LineTo(_rectExtents.right - m_nPadding, cy);
CRect r(_rectExtents.left, _rectExtents.top, _rectExtents.right, cy);
HFONT hOldFont = dc.SelectFont(m_fontTitle);
dc.DrawText(_strHeader, -1, &r,
DT_NOCLIP | DT_VCENTER | DT_CENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX);
dc.SelectFont(hOldFont);
}
dc.SetBkMode(nBkMode);
dc.SetTextColor(clrTextColor);
}
catch(_com_error &e)
{
IW::CMessageBoxIndirect mb;
mb.ShowException(IDS_LOW_LEVEL_ERROR_FMT, e);
}
return true;
}