当前位置: 首页>>代码示例>>C++>>正文


C++ CDCHandle::GetTextColor方法代码示例

本文整理汇总了C++中CDCHandle::GetTextColor方法的典型用法代码示例。如果您正苦于以下问题:C++ CDCHandle::GetTextColor方法的具体用法?C++ CDCHandle::GetTextColor怎么用?C++ CDCHandle::GetTextColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDCHandle的用法示例。


在下文中一共展示了CDCHandle::GetTextColor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:Williamzuckerberg,项目名称:chtmoneyhub,代码行数:31,代码来源:SkinManager.cpp

示例2:

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);
	}
}
开发者ID:Runcy,项目名称:unDonut,代码行数:53,代码来源:ToolBarDialog.cpp

示例3: 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 ;

}
开发者ID:Williamzuckerberg,项目名称:chtmoneyhub,代码行数:46,代码来源:TooltipElem.cpp

示例4: 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);
	}

}
开发者ID:yzx65,项目名称:ndas4windows,代码行数:101,代码来源:nbtreeview.cpp

示例5: _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();
//.........这里部分代码省略.........
开发者ID:charlessoft,项目名称:PicManager,代码行数:101,代码来源:ListViewCtrlEx.cpp

示例6: _DrawTitleItem

void CListViewCtrlEx::_DrawTitleItem( LPDRAWITEMSTRUCT lpdis, const TListItem *pItem )
{
    ATLASSERT(pItem);

    if(pItem->subItems.empty())
        return ;

    int	nWinWidth=lpdis->rcItem.right-lpdis->rcItem.left;
    CRect	rcWindows;
    GetWindowRect(rcWindows);
    if ( nWinWidth > rcWindows.Width())
        nWinWidth = rcWindows.Width()-20;

    int nItem = lpdis->itemID;

    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);
        }
//.........这里部分代码省略.........
开发者ID:charlessoft,项目名称:PicManager,代码行数:101,代码来源:ListViewCtrlEx.cpp


注:本文中的CDCHandle::GetTextColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。