字体的颜色的选择填充

 

    // TODO: Add your command handler code here     //先创建字体     LOGFONT logFont;     memset(&logFont, 0, sizeof(logFont));     logFont.lfHeight = 2400;     logFont.lfCharSet = GB2312_CHARSET;     wcsncpy_s(logFont.lfFaceName,2,_T("隶书"),2);     CFont font;     font.CreateFontIndirect(&logFont);  
    //获取DC      CClientDC dc(this);
CFont* pOldFont = dc.SelectObject(&font); CString str = _T(""); dc.BeginPath(); dc.TextOut(0,0,str); dc.EndPath(); //获取字体的大小 size = dc.GetTextExtent(str); CRect rect(CPoint(0,0),size); dc.SelectObject(pOldFont); font.DeleteObject(); CRgn rgn; CRgn rgnRect; CRgn rgnResult; rgnRect.CreateRectRgn(0,0,size.cx,size.cy); rgnResult.CreateRectRgn(0,0,0,0); rgn.CreateFromPath(&dc); rgnResult.CombineRgn( &rgnRect, &rgn, RGN_DIFF ); CBrush* pBrush = CBrush::FromHandle((HBRUSH)GetStockObject(GRAY_BRUSH)); CBrush* pBrush2 = CBrush::FromHandle((HBRUSH)GetStockObject(BLACK_BRUSH)); CRgn rgnRectLeft; rgnRectLeft.CreateRectRgn(0,0, size.cx/2, size.cy); CRgn rgnRectRight; rgnRectRight.CreateRectRgn(size.cx/2,0, size.cx,size.cy); CRgn rgnResult2; CRgn rgnResult3; rgnResult2.CreateRectRgn(0,0,0,0); rgnResult3.CreateRectRgn(0,0,0,0); rgnResult2.CombineRgn(&rgnRectLeft,&rgnResult,RGN_AND); rgnResult3.CombineRgn(&rgnRectRight,&rgnResult,RGN_AND); //填充字体 dc.FillRgn(&rgnResult2,pBrush); dc.FillRgn(&rgnResult3,pBrush2);

 

你可能感兴趣的:(command,填充,的)