void CMyMainWnd::OnPaint() { CPaintDC myDC(this); CPen myPen; CRect myRect; CFont myFont; CString TypeFace; switch (r) { case 1: myPen.CreatePen(PS_SOLID, 10, RGB(255, 0, 0)); myDC.SelectObject(myPen); myDC.Ellipse(10, 10, 100, 100); break; case 2: myPen.CreatePen(PS_SOLID, 20, RGB(172, 189, 16)); myDC.SelectObject(myPen); myDC.Ellipse(10, 10, 200, 150); break; case 3: myPen.CreatePen(PS_SOLID, 30, RGB(122, 124, 221)); myDC.SelectObject(myPen); myDC.Rectangle(10, 10, 300, 100); break; case 4: myPen.CreatePen(PS_SOLID, 40, RGB(100, 16, 147)); myDC.SelectObject(myPen); myDC.Rectangle(10, 10, 200, 200); break; case 5: myPen.CreatePen(PS_SOLID, 10, RGB(50, 150, 250)); myDC.SelectObject(myPen); myDC.LineTo(50, 50); myDC.LineTo(75, 0); myDC.LineTo(0,0); break; case 0: myPen.CreatePen(PS_SOLID, 6, RGB(62, 106, 110)); myDC.SelectObject(myPen); myDC.Rectangle(0,0,0,0); break; } switch (i) { case 1: myDC.SetTextColor(RGB(255, 0, 0)); TypeFace = "Arial"; myFont.CreateFont(20, 0, 0, 0, FW_BOLD, FALSE, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TypeFace); myDC.SelectObject(myFont); myDC.TextOut(50, 50, L"Text 1"); break; case 2: myDC.SetTextColor(RGB(172, 189, 16)); TypeFace = "Calibri"; myFont.CreateFont(20, 0, 0, 0, FW_BOLD, FALSE, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TypeFace); myDC.SelectObject(myFont); myDC.TextOut(100, 100, L"Text 2"); break; case 3: myDC.SetTextColor(RGB(122, 124, 221)); TypeFace = "Courier"; myFont.CreateFont(20, 0, 0, 0, FW_BOLD, FALSE, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TypeFace); myDC.SelectObject(myFont); myDC.TextOut(150, 150, L"Text 3"); break; case 4: myDC.SetTextColor(RGB(100, 16, 147)); TypeFace = "Cambria"; myFont.CreateFont(20, 0, 0, 0, FW_BOLD, FALSE, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TypeFace); myDC.SelectObject(myFont); myDC.TextOut(200, 200, L"Text 4"); break; case 5: myDC.SetTextColor(RGB(81, 83, 85)); TypeFace = "Segoe Print"; myFont.CreateFont(20, 0, 0, 0, FW_BOLD, FALSE, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TypeFace); myDC.SelectObject(myFont); myDC.TextOut(250, 250, L"Text 5"); break; } }
void CCmgTextArea::DrawText(CDC* pDC,CPoint DrawPoint) { CFont aaa; CFont* OldFont; BOOL ret; switch (m_nTextFont) { case TEXTFONT_WIN_LOOSE: ret=aaa.CreateFont(20,10,0,0,FW_BOLD,0,0,0,ANSI_CHARSET,OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS,PROOF_QUALITY,FIXED_PITCH,CString("Courier New")); break; case TEXTFONT_FIELD: ret=aaa.CreateFont(12,0,0,0,FW_REGULAR,0,0,0,ANSI_CHARSET,OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS,PROOF_QUALITY,FIXED_PITCH,CString("Verdana")); break; case TEXTFONT_FIELD_B: ret=aaa.CreateFont(12,0,0,0,FW_BOLD,0,0,0,ANSI_CHARSET,OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS,PROOF_QUALITY,FIXED_PITCH,CString("Verdana")); break; case TEXTFONT_SCORE: ret=aaa.CreateFont(14,0,0,0,FW_REGULAR,0,0,0,ANSI_CHARSET,OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS,PROOF_QUALITY,FIXED_PITCH,CString("Courier New")); break; case TEXTFONT_SCORE_B: ret=aaa.CreateFont(14,0,0,0,FW_BOLD,0,0,0,ANSI_CHARSET,OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS,PROOF_QUALITY,FIXED_PITCH,CString("Courier New")); break; default: ASSERT(0); } if (ret) OldFont=pDC->SelectObject(&aaa); COLORREF OldTextColor=pDC->SetTextColor(m_nTextColor); COLORREF OldBkColor=pDC->SetBkColor(m_nBkColor); pDC->SetBkMode(TRANSPARENT); CPoint p1=m_rArea.TopLeft(); p1.x-=DrawPoint.x; p1.y-=DrawPoint.y; #ifdef WIN32 pDC->ExtTextOut(p1.x,p1.y,0,m_rArea,m_sText,NULL); #else pDC->ExtTextOut(p1.x,p1.y,0,m_rArea,LPCSTR(m_sText),m_sText.GetLength(),NULL); #endif pDC->SetBkColor(OldBkColor); pDC->SetTextColor(OldTextColor); if (ret) pDC->SelectObject(OldFont); }
//绘画函数 void CGameParrentView::OnPaint() { CPaintDC dc(this); //判断模式 if (m_pThreadDraw!=NULL) return; //获取位置 CRect ClientRect; GetClientRect(&ClientRect); //重画缓冲区 if ((m_bDoubleBuf==true)&&(m_ImageBuffer.IsNull()==false)) { if (m_bReDraw==true) { //创建字体 CFont DrawFont; DrawFont.CreateFont(-12,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("宋体")); CDC * pDC=CDC::FromHandle(m_ImageBuffer.GetDC()); CFont * pOldFont=pDC->SelectObject(&DrawFont); //更新缓冲 m_bReDraw=false; pDC->SetBkMode(TRANSPARENT); pDC->FillSolidRect(0,0,ClientRect.Width(),ClientRect.Height(),RGB(0,0,150)); DrawGameView(pDC,ClientRect.Width(),ClientRect.Height()); // DrawGameViewFrame(pDC,ClientRect.Width(),ClientRect.Height()); //清理资源 pDC->SelectObject(pOldFont); m_ImageBuffer.ReleaseDC(); DrawFont.DeleteObject(); } //绘画界面 CRect rcClip; dc.GetClipBox(&rcClip); m_ImageBuffer.BitBlt(dc,rcClip.left,rcClip.top,rcClip.Width(),rcClip.Height(),rcClip.left,rcClip.top); } else { //创建字体 CFont DrawFont; DrawFont.CreateFont(-12,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("宋体")); CFont * pOldFont=dc.SelectObject(&DrawFont); //绘画界面 dc.SetBkMode(TRANSPARENT); DrawGameView(&dc,ClientRect.Width(),ClientRect.Height()); // DrawGameViewFrame(&dc,ClientRect.Width(),ClientRect.Height()); //清理资源 dc.SelectObject(pOldFont); DrawFont.DeleteObject(); } return; }
void CVideoPane::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here // Do not call CDialog::OnPaint() for painting messages // 绘制标题栏 if (NULL != m_pImgCaption) { // 设置坐标 CRect rect; GetClientRect(rect); Gdiplus::Rect gRect(rect.left, rect.top, rect.right, CAPTION_HEIGHT); Gdiplus::ImageAttributes ImgAtt; ImgAtt.SetWrapMode(Gdiplus::WrapModeTileFlipXY); Gdiplus::Graphics graphics(dc); graphics.DrawImage(m_pImgCaption, gRect, 0, 0, (INT)m_pImgCaption->GetWidth(), (INT)m_pImgCaption->GetHeight(), Gdiplus::UnitPixel, &ImgAtt); } // 标题栏文本 CRect rect; GetClientRect(rect); rect.left += BTN_CLOSE_SPACE; rect.bottom = CAPTION_HEIGHT; dc.SetBkMode(CAPTION_FONT_BKCLR); dc.SetTextColor(CAPTION_FONT_COLOR); CFont font; font.CreateFont(CAPTION_FONT_SIZE, 0, 0, 0, FW_NORMAL, FALSE,FALSE,FALSE,0,0,0,0,0,CAPTION_FONT_NAME); dc.SelectObject(font); dc.DrawText(m_strCaptionText, -1, &rect, DT_SINGLELINE | DT_VCENTER); }
void CDlgLeftShow::OnPaint() { CPaintDC dc(this); CGameImageHelper handle(&m_bkimage); handle.BitBlt(dc.GetSafeHdc(),0,0); int y=25; TCHAR szBuffer[200]; memset(szBuffer,0,sizeof(szBuffer)); // WCHAR wszBuffer[200]; dc.SetTextColor(RGB(146,220,255)); dc.SetBkMode(TRANSPARENT); //图片 /*::lstrcpy(szBuffer,TEXT("image\\log\\gamelog%ld.png")); MultiByteToWideChar(CP_ACP,MB_COMPOSITE,szBuffer,-1,wszBuffer,sizeof(wszBuffer)); Graphics graphics(dc.GetSafeHdc()); // Create a GDI+ graphics object Image image(wszBuffer); // Construct an image graphics.DrawImage(&image, 125, 4, image.GetWidth(), image.GetHeight());*/ CFont font; font.CreateFont(15,0,0,0,400,NULL,NULL,NULL,134,3,2,1,2,TEXT("宋体")); dc.SelectObject(font); //妮称 wsprintf(szBuffer,TEXT("%s"),m_nickName); CRect rect(115,45,230,60); dc.DrawText(szBuffer,lstrlen(szBuffer),&rect,DT_CENTER|DT_TOP|DT_END_ELLIPSIS); font.DeleteObject(); }
void CShowScore::OnPaint() { CPaintDC dc(this); dc.SetBkMode(TRANSPARENT); CFont font; font.CreateFont(-12,0,0,0,400,NULL,NULL,NULL,134,3,2,1,2,TEXT("宋体")); dc.SelectObject(&font); dc.SetTextColor(m_textcr); CGameImageHelper handle(&m_bk); handle.BitBlt(dc.GetSafeHdc(),0,0); TCHAR sz[100]; CRect rect; for(int i = 0; i < MAX_PEOPLE; i ++) { if(m_pUserItem[i] == NULL) continue; wsprintf(sz,"%s",m_pUserItem[i]->GameUserInfo.nickName); rect.left=m_listx; rect.right=rect.left+m_w1; rect.top=m_listy+i*(m_itemh+w); rect.bottom=rect.top+m_itemh; dc.DrawText(sz,lstrlen(sz),&rect,DT_CENTER|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); wsprintf(sz,"%d",m_lastscore[i]); rect.left=m_listx+m_w1+w; rect.right=rect.left+m_w2; rect.top=m_listy+i*(m_itemh+w); rect.bottom=rect.top+m_itemh; dc.DrawText(sz,lstrlen(sz),&rect,DT_CENTER|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); wsprintf(sz,"%d",m_allscore[i]); rect.left=m_listx+m_w1+w*2+m_w3-5; rect.right=rect.left+m_w3; rect.top=m_listy+i*(m_itemh+w); rect.bottom=rect.top+m_itemh; dc.DrawText(sz,lstrlen(sz),&rect,DT_CENTER|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); //if(m_ucomtype==TY_MONEY_GAME) { TCHAR szNum[128]; GetNumString(szNum, m_lastmoney[i], Glb().m_nPowerOfGold,Glb().m_bUseSpace, Glb().m_strSpaceChar); wsprintf(sz,"%s",szNum); rect.left=m_listx+m_w1+m_w2+m_w3+w*3-2; rect.right=rect.left+m_w4; rect.top=m_listy+i*(m_itemh+w); rect.bottom=rect.top+m_itemh; dc.DrawText(sz,lstrlen(sz),&rect,DT_CENTER|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); //wsprintf(sz,"%d",m_allmoney[i]); GetNumString(szNum, m_allmoney[i], Glb().m_nPowerOfGold,Glb().m_bUseSpace, Glb().m_strSpaceChar); wsprintf(sz,"%s",szNum); rect.left=m_listx+m_w1+m_w2+m_w3+w+m_w4; rect.right=rect.left+m_w5; rect.top=m_listy+i*(m_itemh+w); rect.bottom=rect.top+m_itemh; dc.DrawText(sz,lstrlen(sz),&rect,DT_CENTER|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); } } }
void QuoteTableCtrlGeneralSort::OnDraw(CDC* pDC) { CHSGridCtrl::OnDraw(pDC); CRect rect, itemrect, rccvlient; GetClientRect(rccvlient); ClientToScreen(rccvlient); GetClientRect(rect); itemrect = rect; if (GetRowCount() <=0) return; int rowheight = GetRowHeight(0); itemrect.bottom = rowheight-1; COLORREF bkcolor = GetBkColor(); COLORREF textcolor = RGB(155,155,155); if (m_iColorFontProt) textcolor = m_iColorFontProt->GetQuoteTabTextColor(); CFont* pFont; CFont* pOldFont; BOOL bCreat = FALSE; if (m_iFont) pFont = (CFont*)m_iFont->GetQuoteColHeadFont(); else { pFont = new CFont(); VERIFY(pFont->CreateFont(16,0, 0,0,FW_NORMAL,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("宋体"))); bCreat = TRUE; } pOldFont = pDC->SelectObject(pFont); pDC->SetBkColor( GetSysColor(COLOR_HIGHLIGHT) ); pDC->SetBkColor(bkcolor); pDC->SetTextColor(textcolor); pDC->SetBkColor(bkcolor); pDC->DrawText(m_pTableFlag->strTitle, &itemrect, DT_CENTER | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER); pDC->SelectObject(pOldFont); if (bCreat) pFont->DeleteObject(); CPen hPen; hPen.CreatePen(PS_SOLID ,1,RGB(200,0,0)); CPen* hOldPen = pDC->SelectObject(&hPen); pDC->MoveTo(CPoint(itemrect.left,itemrect.bottom)); pDC->LineTo(CPoint(itemrect.right, itemrect.bottom)); pDC->SelectObject(hOldPen); hPen.DeleteObject(); }
void CDiagramCombobox::Draw( CDC* dc, CRect rect ) /* ============================================================ Function : CDiagramCombobox::Draw Description : Draws the "control" Return : void Parameters : CDC* dc - CDC to draw to CRect rect - Total object rect (zoomed) Usage : ============================================================*/ { CStdGrfx::drawsunkenframed3dWindow( dc, rect ); LOGFONT lf; GetFont( lf ); dc->SetBkMode( TRANSPARENT ); dc->SetTextColor( ::GetSysColor( COLOR_BTNTEXT ) ); CRect rectArrow( rect ); rectArrow.left = rectArrow.right - ( int ) ( ( double ) GetMinimumSize().cy * GetZoom() ); rectArrow.InflateRect( -2, -2 ); CStdGrfx::drawframed3dBox( dc, rectArrow ); CFont chk; chk.CreateFont( lf.lfHeight, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DECORATIVE, "Marlett" ); dc->SelectObject( &chk ); dc->DrawText( "u", rectArrow, DT_VCENTER | DT_SINGLELINE | DT_CENTER ); dc->SelectStockObject( DEFAULT_GUI_FONT ); }
void CResultDialog::Initialize() { // Set Fixed Width Font for rich edit control CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog); CFont aFixedWidthFont; VERIFY(aFixedWidthFont.CreateFont( 15, // nHeight 5, // nWidth 0, // nEscapement 0, // nOrientation FW_NORMAL, // nWeight FALSE, // bItalic FALSE, // bUnderline 0, // cStrikeOut ANSI_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality FF_MODERN, // Fix width fonts are FF_MODERN L"Courier New")); // lpszFacename pEd->SetFont(&aFixedWidthFont, false); // save button's width and height, so they are calculated only once RECT rect; CWnd *pBCopy = (CWnd *) GetDlgItem (IDC_CopySelectionToClipboard); pBCopy->GetWindowRect(&rect); bw = rect.right - rect.left; // a button's width (they are all equal) bh = rect.bottom - rect.top; // a button's height }
void CDiagramRadiobutton::Draw( CDC* dc, CRect rect ) /* ============================================================ Function : CDiagramRadiobutton::Draw Description : Draws the "control" Return : void Parameters : CDC* dc - CDC to draw to CRect rect - Total object rect (zoomed) Usage : ============================================================*/ { dc->SelectObject( CStdGrfx::dialogBrush() ); dc->SelectObject( CStdGrfx::dialogPen() ); dc->Rectangle( rect ); LOGFONT lf; CFont chk; CFont font; GetFont( lf ); // MS Sans Serif will not scale below 8 pts if( GetZoom() < 1 ) lstrcpy( lf.lfFaceName, _T( "Arial" ) ); font.CreateFontIndirect( &lf ); // Marlett is used for the circle chk.CreateFont( ( int ) ( ( double ) lf.lfHeight * 1.25 ), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DECORATIVE, "Marlett" ); dc->SetBkMode( TRANSPARENT ); dc->SelectObject( &chk ); dc->SetTextColor( ::GetSysColor( COLOR_WINDOW ) ); dc->TextOut( rect.left, rect.top, "n" ); dc->SetTextColor( ::GetSysColor( COLOR_3DSHADOW ) ); dc->TextOut( rect.left, rect.top, "j" ); dc->SetTextColor( ::GetSysColor( COLOR_3DHIGHLIGHT ) ); dc->TextOut( rect.left, rect.top, "k" ); dc->SetTextColor( ::GetSysColor( COLOR_3DDKSHADOW ) ); dc->TextOut( rect.left, rect.top, "l" ); dc->SetTextColor( ::GetSysColor( COLOR_3DLIGHT ) ); dc->TextOut( rect.left, rect.top, "m" ); dc->SelectObject( &font ); dc->SetTextColor( ::GetSysColor( COLOR_BTNTEXT ) ); rect.left += ( int ) ( ( double ) abs( lf.lfHeight ) * 1.5 ); dc->DrawText( GetTitle(), rect, DT_SINGLELINE ); dc->SelectStockObject( DEFAULT_GUI_FONT ); dc->SelectStockObject( BLACK_PEN ); dc->SelectStockObject( WHITE_BRUSH ); }
void InfoFrom::OnInitialUpdate() { CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(); CRect m_wndRect; GetClientRect(&m_wndRect); CRect m_headerRect; // create the header { m_headerRect.left = m_headerRect.top = -1; m_headerRect.right = m_wndRect.Width(); m_treeList.m_wndHeader.Create(WS_CHILD | WS_VISIBLE | HDS_BUTTONS | HDS_HORZ, m_headerRect, this, ID_TREE_LIST_HEADER); } static CFont font; font.CreateFont(100, 0, 0, 0, FW_NORMAL, FALSE,FALSE,FALSE,GB2312_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH|FF_MODERN,"宋体"); //m_treeList.m_wndHeader.SetFont(&font); m_treeList.SetFont(&font); CSize textSize; // set header's pos, dimensions and image list { CDC *pDC = m_treeList.m_wndHeader.GetDC(); pDC->SelectObject(&m_treeList.m_headerFont); textSize = pDC->GetTextExtent("A"); m_treeList.m_wndHeader.SetWindowPos(&wndTop, 0, 0, m_headerRect.Width(), textSize.cy+4, SWP_SHOWWINDOW); //m_treeList.m_cImageList.Create(IDB_HEADER, 16, 10, 0); //m_treeList.m_wndHeader.SetImageList(&m_treeList.m_cImageList); m_treeList.m_wndHeader.UpdateWindow(); } CRect m_treeListRect; // create the tree itself { GetClientRect(&m_wndRect); m_treeListRect.left=0; m_treeListRect.top = textSize.cy+4; m_treeListRect.right = m_headerRect.Width()-5; m_treeListRect.bottom = m_wndRect.Height()-GetSystemMetrics(SM_CYHSCROLL)-4; m_treeList.Create(WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS, m_treeListRect, this, ID_TREE_LIST_CTRL); } m_treeList.InsertColumn(0, "名称", LVCFMT_LEFT, 360); m_treeList.InsertColumn(1, "详细内容", LVCFMT_LEFT, 360); m_init = TRUE; SortTree(0, TRUE, m_treeList.GetRootItem()); }
void CGreedySnakeView::drawGameOver() { CClientDC dc(this); CDC memDC; CRect rectClient; GetClientRect(rectClient); memDC.CreateCompatibleDC(&dc); memDC.SelectObject(&m_bmpGameOver); dc.BitBlt(0, 0, rectClient.right, rectClient.bottom, &memDC, 400, 400, SRCCOPY); CFont font; font.CreateFont(120, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("Arial")); dc.SelectObject(&font); dc.SetBkMode(TRANSPARENT); dc.SetTextColor(::GetSysColor( COLOR_3DHILIGHT)); dc.DrawText( _T(" Game Over! "), CRect(12, 230, 800, 330), DT_SINGLELINE | DT_LEFT |DT_VCENTER|DT_CENTER); dc.SelectStockObject(BLACK_BRUSH); font.DeleteObject(); memDC.DeleteDC(); }
void CDlgDIYChat::OnPaint() { CPaintDC dc(this); /*// 2012.12.17 yyf 屏蔽 CGameImageHelper handle(&m_bkimage); handle.BitBlt(dc.GetSafeHdc(),0,0);*/ //绘画框架底图 2012.10.17 yyf m_configDlg.DrawViewFrame(&dc); CFont Font;//,*OldFont; Font.CreateFont(15,10,0,0,0,0,0,0,GB2312_CHARSET ,3,2,1,2,TEXT("宋体")); CWnd *pWnd=GetDlgItem(IDC_LIST_CHAT); CDC *pDC=pWnd->GetDC(); pDC->SelectObject(&Font); pWnd->SetFont(&Font,true); // DeleteObject(pDC->SelectObject(OldFont)); ReleaseDC(pDC); pWnd=GetDlgItem(IDC_EDIT1); pDC=pWnd->GetDC(); pDC->SelectObject(&Font); pWnd->SetFont(&Font,true); // DeleteObject(pDC->SelectObject(OldFont)); ReleaseDC(pDC); }
void CConfigDlg::ReadCfg() { SDComCfg *pDComCfg; UINT nBytes; CFont font; if (m_bDComCfgValid == false) { memset(&m_sDComCfgReal, 0, sizeof(m_sDComCfgReal)); m_bDComCfgValid = true; m_sDComCfgReal.m_crFore = RGB(0xcc, 0xcc, 0xcc); m_sDComCfgReal.m_crBack = RGB(0x00, 0x00, 0x00); font.CreateFont(12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _T("Courier")); font.GetLogFont(&m_sDComCfgReal.m_logfont); m_sDComCfgReal.m_nNumLines = 20000; m_sDComCfgReal.m_nWinWidth = 0; if (AfxGetApp()->GetProfileBinary(DCOM_SETTINGS_SECTION, DCOM_SETTINGS_CONFIG, (LPBYTE*)&pDComCfg, &nBytes) == TRUE) { if (nBytes <= sizeof(SDComCfg)) { memcpy(&m_sDComCfgReal, pDComCfg, nBytes); if (nBytes < sizeof(SDComCfg)) { memset(((char*)(&m_sDComCfgReal)) + nBytes, 0, sizeof(SDComCfg) - nBytes); } } delete pDComCfg; } memcpy(&m_sDComCfgTmp, &m_sDComCfgReal, sizeof(SDComCfg)); } }
VOID CAboutDlg::SetCtrlFont(INT IDC_STATIC_CTRL,UINT nFontSize) { CStatic *pStatic = reinterpret_cast<CStatic *>(GetDlgItem(IDC_STATIC_CTRL)); ASSERT(pStatic); CFont pFont; VERIFY(pFont.CreateFont( nFontSize, // nHeight 0, // nWidth 0, // nEscapement 0, // nOrientation FW_BLACK, // nWeight FALSE, // bItalic FALSE, // bUnderline FALSE, // cStrikeOut ANSI_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily _T("Microsoft Sans Serif"))); // lpszFacename pStatic->SetFont(&pFont, TRUE); }
CFont* vmsUiFonts::Tahoma_11bold() { static CFont fnt; if (fnt.m_hObject == NULL) fnt.CreateFont (-11, 0, 0, 0, FW_BOLD, 0, FALSE, 0, DEFAULT_CHARSET, 0, 0, 0, 0, _T ("Tahoma")); return &fnt; }
CFont* vmsUiFonts::Tahoma_11underline() { static CFont fnt; if (fnt.m_hObject == NULL) fnt.CreateFont (-11, 0, 0, 0, FW_NORMAL, 0, TRUE, 0, DEFAULT_CHARSET, 0, 0, 0, 0, _T ("Tahoma")); return &fnt; }
//»æ»³ïÂë void CGoldView::DrawGoldView(CDC * pDC, int nXPos, int nYPos) { //¼ÓÔØλͼ CImageHandle ImageHandle(&m_ImageGold); //»æ»ÅÐ¶Ï if (m_lGold<=0L) return; //»ñÈ¡ÊôÐÔ INT nJettonHeight=m_ImageGold.GetHeight(); INT nJettonWidth=m_ImageGold.GetWidth()/3; //»æ»³ïÂë INT nXPos1=nXPos-nJettonWidth/2; INT nYPos1=nYPos-nJettonHeight/2; m_ImageGold.AlphaDrawImage(pDC,nXPos1,nYPos1,nJettonWidth,nJettonHeight,nJettonWidth*m_nGoldIndex,0,RGB(255,0,255)); //»Êý×Ö TCHAR szNum[64]; //_snprintf( szNum,CountArray(szNum),TEXT("%ld"),m_lScore ); GetGlodString( m_lGold,szNum ); CRect rcNum( nXPos1,nYPos1,nXPos1+nJettonWidth,nYPos1+nJettonHeight ); //´´½¨×ÖÌå CFont ViewFont; ViewFont.CreateFont(-12,0,0,0,700,0,0,0,134,3,2,1,1,TEXT("ËÎÌå")); COLORREF OldClr = pDC->SetTextColor(RGB(0x0, 0x10, 0x70)); CFont * pOldFont=pDC->SelectObject(&ViewFont); pDC->DrawText( szNum,lstrlen(szNum),&rcNum,DT_VCENTER|DT_CENTER|DT_SINGLELINE|DT_END_ELLIPSIS ); pDC->SetTextColor(OldClr); //ÇåÀí×ÊÔ´ pDC->SelectObject(pOldFont); return; }
/************************************************************* PutText desc : DDB의 지정한 영역 안에만 글씨를 출력한다. arg : x, y = 글씨가 출력될 영역의 시작 좌표 dx, dy = 글씨를 출력할 영역의 끝 좌표 혹은 크기 nSize = 글씨 크기 lpszFont = 글씨 폰트 lpszMsg = 출력 내용 color = 색상 nStyle = 글씨 스타일 ( TS_BOLD | TS_ITALIC | TS_UDLINE) nAlign = 글씨 정렬( DT_LEFT | DT_CENTER | DT_RIGHT | DT_TOP | DT_VCENTER | DT_BOTTOM) ret : none ex : PutText( 200, 100, 300, 200, 14, "굴림", "PutText 예제", TS_BOLD, DT_CENTER|DT_VCENTER, RGB(255,255,255), TS_BOLD, DT_CENTER); **************************************************************/ void CDDB::PutText( int x, int y, int dx, int dy, int nSize, LPCTSTR lpszFont, LPCTSTR lpszMsg, COLORREF color, UINT nStyle, UINT nAlign) { if ( color != NOCOLOR) m_nColor = color; // Set color // Coordinate mode is not absolute if ( m_CoordinateMode != CM_ABSOLUTE) GetAbsoluteCoordinate( &x, &y, &dx, &dy); // Put text UINT nBold = (nStyle & TS_BOLD) ? FW_BOLD : FW_NORMAL; BYTE bItalic = (nStyle & TS_ITALIC) ? true : false; BYTE bUnderLine = (nStyle & TS_UDLINE) ? true : false; CFont font; font.CreateFont( nSize, 0, 0, 0, nBold, bItalic, bUnderLine, 0, ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, lpszFont); CFont *pOldFont = (CFont *)m_DC.SelectObject( &font); CRect rect; rect.top = y; rect.left = x; rect.right = dx; rect.bottom = dy; m_DC.SetTextColor( m_nColor); m_DC.DrawText( lpszMsg, (LPRECT)rect, nAlign); m_DC.SelectObject( pOldFont); }
void EditTxt::OnInitialUpdate() { CFont * f; CEdit & n_edit=GetEditCtrl(); CEditView::OnInitialUpdate(); CMainFrame *pFrm=(CMainFrame *)AfxGetMainWnd(); pFrm->m_edit=(EditTxt*)this; // TODO: Add your specialized code here and/or call the base class pEdit=&n_edit; //设置字体 f = new CFont; f->CreateFont(15, // nHeight 0, // nWidth 0, // nEscapement 0, // nOrientation 0, // nWeight FALSE, // bItalic FALSE, // bUnderline 0, // cStrikeOut ANSI_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily _T("Arial")); // lpszFac pEdit->SetFont(f); //IDC_EDIT_RECEIVE是Edit框标号 }
void LxDcViCtl::init(CDC* pDC, FILE* file) { clear(); build_from_stream(file); CFont* font = new CFont; font->CreateFont(-18, 0, 0, 0, 100, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_SWISS, L"Consolas"); LOGFONT logfont; font->GetLogFont(&logfont); default_font_index = SrcFontFactory::GetFontFactInstance()->insert_src_font(logfont); default_color_index = RGB(0, 50, 150); delete font; if (font_tree.empty() && color_tree.empty()) { font_tree.insert(0, 0, default_font_index); color_tree.insert(0, 0, default_color_index); } compose_doc.AttachColorInfo(&color_tree); compose_doc.AttachFontInfo(&font_tree); compose_doc.AttachPhyDoc(&document); compose_doc.compose_complete(pDC); compose_doc.calc_cursor(cursor, 0, *document.begin(), pDC); section.cursor_begin = cursor; section.cursor_end = cursor; section.trace = false; gd_proxy.init(); calc_font_color(); render = new LxScrollRender(new LxBorderRender(new LxContexRender(&compose_doc, &gd_proxy))); }
void CWorkspaceView::ShowFont2(CDC* pDC, int& nxPos, int& nyPos, int nPoints, CString text) { TEXTMETRIC tm; CFont fontText; CString strText; CSize sizeText; fontText.CreateFont(-nPoints * 20, 0, 0, 0, 400, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("Times New Roman")); CFont* pOldFont = (CFont*) pDC->SelectObject(&fontText); pDC->GetTextMetrics(&tm); TRACE(_T("puntos = %d, tmHeight = %d, tmInternalLeading = %d,") _T(" tmExternalLeading = %d\n"), nPoints, tm.tmHeight, tm.tmInternalLeading, tm.tmExternalLeading); strText.Format(text, nPoints); sizeText = pDC->GetTextExtent(strText); TRACE(_T("anchura de cadena = %d, altura de cadena = %d\n"), sizeText.cx, sizeText.cy); pDC->TextOut(nxPos, nyPos, strText); pDC->SelectObject(pOldFont); nyPos -= tm.tmHeight + tm.tmExternalLeading; }
void CHexView::OnDraw(CDC* pDC) { // hex dump of document strings int i, j, k, l, n, nHeight; CString outputLine, str; CFont font; TEXTMETRIC tm; CPoemDoc* pDoc = GetDocument(); font.CreateFont(-160, 80, 0, 0, 400, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial"); CFont* pOldFont = pDC->SelectObject(&font); pDC->GetTextMetrics(&tm); nHeight = tm.tmHeight + tm.tmExternalLeading; j = pDoc->m_stringArray.GetSize(); for (i = 0; i < j; i++) { outputLine.Format("%02x ", i); l = pDoc->m_stringArray[i].GetLength(); for (k = 0; k < l; k++) { n = pDoc->m_stringArray[i][k] & 0x00ff; str.Format("%02x ", n); outputLine += str; } pDC->TextOut(720, -i * nHeight - 720, outputLine); } pDC->SelectObject(pOldFont); }
BOOL CEX32ASrvrItem::OnDraw(CDC* pDC, CSize& rSize) { CEX32ADoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDC) return FALSE; // rSize를 사용할 경우 이 줄을 제거하십시오. UNREFERENCED_PARAMETER(rSize); // TODO: 매핑 모드와 범위를 설정합니다. // 범위는 보통 OnGetExtent에서 반환된 크기와 같습니다. pDC->SetMapMode(MM_ANISOTROPIC); pDC->SetWindowOrg(0,0); pDC->SetWindowExt(3000, 3000); // TODO: 여기에 그리기 코드를 추가합니다. 옵션으로 HIMETRIC 범위를 채울 수도 있습니다. // 모든 그리기 작업은 메타 파일 디바이스 컨텍스트(pDC)에서 발생합니다. CFont font; font.CreateFont(-5000, 0, 0, 0, 400, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, L"Arial"); CFont* pFont = pDC->SelectObject(&font); CRect rectEllipse(CRect(500, -500, 2500, -2500)); pDC->Ellipse(rectEllipse); pDC->TextOutW(0, 0, pDoc->m_strText); pDC->SelectObject(pFont); return TRUE; }
LRESULT OnPaint( HWND hWnd ) { CWnd* pWnd = CWnd::FromHandle(hWnd); CPaintDC dc(pWnd); CString Text; CRect RC; CFont Font; CFont *pOldFont; CBrush Brush; CBrush *pOldBrush; CPoint PT(2,2); dc.SetBkMode( TRANSPARENT ); Font.CreateFont( 12, 0, 0, 0, FW_HEAVY, 0, 0, 0, ANSI_CHARSET, \ OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, \ VARIABLE_PITCH | FF_SWISS, "MS Sans Serif" ); pOldFont = dc.SelectObject( &Font ); if( m_State == bsNormal) { if (m_Style==2) { CBitmap bmp; bmp.LoadBitmap(IDB_BKBUTTON); Brush.CreatePatternBrush(&bmp); } else Brush.CreateSolidBrush( RGB( 200, 200, 200 ) ); dc.SetTextColor( RGB( 80, 80, 80) ); } else if( m_State == bsDown ) { Brush.CreateSolidBrush( RGB( 160, 160, 160 ) ); dc.SetTextColor( RGB( 50, 50, 250 ) ); } else if( m_State == bsHot ) { Brush.CreateSolidBrush( RGB( 100, 100, 180 ) ); dc.SetTextColor( RGB( 250, 250, 0 ) ); } pOldBrush = dc.SelectObject( &Brush ); pWnd->GetClientRect( &RC ); dc.RoundRect( &RC, PT ); HRGN hRgn = CreateRectRgn( RC.left, RC.top, RC.right, RC.bottom ); pWnd->SetWindowRgn( hRgn, TRUE ); DeleteObject( hRgn ); pWnd->GetWindowText(Text ); dc.DrawText( Text, &RC, DT_CENTER | DT_VCENTER | DT_SINGLELINE ); dc.SelectObject( pOldFont ); dc.SelectObject( pOldBrush ); return TRUE; }
//绘画函数 void CShortMessage::OnPaint() { CPaintDC dc(this); //绘画界面 CRect ClientRect; GetClientRect(&ClientRect); // this->MapWindowPoints(this->GetParent(),&ClientRect); // DrawBackFace(&dc,0,0,ClientRect.Width(),ClientRect.Height()); CGameImageHelper help(&m_bk); // this->MoveWindow(ClientRect.left,ClientRect.top,help.GetWidth(),help.GetHeight()); help.BitBlt(dc.GetSafeHdc(),0,0); //绘画用户 TCHAR szBuffer[100]; memset(szBuffer,0,sizeof(szBuffer)); dc.SetTextColor(RGB(255,255,255)); dc.SetBkMode(TRANSPARENT); CFont font; font.CreateFont(-12,0,0,0,700,NULL,NULL,NULL,134,3,2,1,2,TEXT("宋体")); dc.SelectObject(font); if (m_iGmID == 0) wsprintf(szBuffer,"与 %s 聊天中",m_strTargerName); else wsprintf(szBuffer,"系统消息:%s",m_strTargerName); CRect rect(0,10,help.GetWidth(),40); dc.DrawText(szBuffer,lstrlen(szBuffer),&rect,DT_CENTER); this->SetWindowText(szBuffer); return; }
BOOL CPassWordDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here CFont * f; f = new CFont; f->CreateFont(40, // nHeight 0, // nWidth 0, // nEscapement 0, // nOrientation FW_BOLD, // nWeight FALSE, // bItalic FALSE, // bUnderline 0, // cStrikeOut ANSI_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily _T("Arial")); // lpszFac GetDlgItem(IDC_INPUT)->SetFont(f); //IDC_EDIT_RECEIVE是Edit框标号 return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
//绘制消息 void CDLGMBCard::OnDrawClientArea(CDC * pDC, INT nWidth, INT nHeight) { //创建字体 CFont DrawFont; DrawFont.CreateFont(-23,0,0,0,700,0,0,0,134,3,2,1,2,TEXT("宋体")); //设置环境 CFont * pOldFont = pDC->SelectObject(&DrawFont); COLORREF crOldColor = pDC->SetTextColor(RGB(0,0,255)); int iOldMode = pDC->SetBkMode(TRANSPARENT); //绘制信息 CString strCoordinate,strTmp; for (int i=0; i<3; ++i) { strTmp.Format(TEXT("%c%d "),m_szRandLetter[i],m_szRandNumber[i]); strCoordinate+=strTmp; } pDC->TextOut(140,46,strCoordinate); //还原设置 pDC->SelectObject(pOldFont); pDC->SetTextColor(crOldColor); pDC->SetBkMode(iOldMode); DrawFont.DeleteObject(); }
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 ; }
void CMainFrame::OnPaint() { CPaintDC pDC(this); // device context for painting // TODO: 在此处添加消息处理程序代码 #if 1 CFont NewFont; NewFont.CreateFont(16, // nHeight 字体高度 0, // nWidth 字体宽度 0, // nEscapement 字体显示的角度 0, // nOrientation 字体的角度 FW_NORMAL, //FW_NORMAL,//FW_BOLD, // nWeight 字体的磅数 //FW_MEDIUM FALSE, // bItalic 斜体字体 FALSE, // bUnderline带下划线的字体 0, // cStrikeOut 带删除线的字体 GB2312_CHARSET, //ANSI_CHARSET, // nCharSet 所需的字符集 OUT_DEFAULT_PRECIS, // nOutPrecision 输出的精度 CLIP_DEFAULT_PRECIS, // nClipPrecision 裁减的精度 DEFAULT_QUALITY, // nQuality逻辑字体与输出设备的实际 //字体之间的精度 DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily 字体间距和字体集 _T("幼圆") //Arial 字体名称 ); CFont *pOldFont = pDC.SelectObject(&NewFont); pDC.SetBkMode(TRANSPARENT); //选进设备描述表 pDC.SetTextColor(RGB(255,0,0)); //设置字体颜色,这里是红色 pDC.TextOut(100,10,_T("西南科技大学视频监控系统")); pDC.SelectObject(&pOldFont); // 回复到旧字体 NewFont.DeleteObject(); // 删除新创建的字体 // 不为绘图消息调用CBkDialogST::OnPaint() #endif }