void CTab4::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: 在此处添加消息处理程序代码 CFont font; font.CreatePointFont(100, _T("微软雅黑")); //选择字体 m_edit.SetFont(&font); font.CreatePointFont(150, _T("微软雅黑")); m_title.SetFont(&font); pPic = (CStatic*)GetDlgItem(IDC_STATIC);//获取控件 pDC = pPic->GetWindowDC();//获取设备环境 if (firstrun) { pPic->GetClientRect(r); x_m = r.Width(); y_m = r.Height(); MemDC.CreateCompatibleDC(pDC); bm.CreateCompatibleBitmap(pDC, x_m, y_m); MemDC.SelectObject(&bm); InitTable(); firstrun = false; } pDC->BitBlt(0, 0, x_m, y_m, &MemDC, 0, 0, SRCAND); // 不为绘图消息调用 CDialogEx::OnPaint() }
void CTalk::OnDraw(CDC &dc) { //边框 int nWidth = 6; CRect Rect(CPoint(300, 200), CSize(nWidth * TILE_WIDTH, 2 * TILE_HEIGHT)); int i, j; for(i = 0; i < Rect.Width() / TILE_WIDTH; i++) { for(j = 0; j < Rect.Height() / TILE_HEIGHT; j++) { Tile.Draw(dc, Rect.left + i * TILE_WIDTH, Rect.top + j * TILE_HEIGHT, TILE_FLOOR); } } COLORREF crBorderColor = BORDER_COLOR; int nBorderWidth = 5; CBrush Brush(crBorderColor); for(i = 0; i < nBorderWidth; i++) { Rect.InflateRect(1, 1); dc.FrameRect(&Rect, &Brush); } //设置显示字体 int nFontSize = 12; //显示说话内容 CFont Font; Font.CreatePointFont(nFontSize * 10, "Roman"); dc.SelectObject(&Font); dc.SetTextColor(RGB(255, 180, 0)); dc.SetBkMode(TRANSPARENT); Tile.Draw(dc, Rect.left + TILE_WIDTH / 4, Rect.top + TILE_HEIGHT / 4, Talk[m_idTalk].idTile[nTileIndex]); dc.TextOut(Rect.left + TILE_WIDTH + TILE_WIDTH / 2 , Rect.top + TILE_HEIGHT / 2, Talk[m_idTalk].szName, strlen(Talk[m_idTalk].szName)); dc.TextOut(Rect.left + TILE_WIDTH + TILE_WIDTH / 2 + nFontSize * 4, Rect.top + TILE_HEIGHT / 2, Talk[m_idTalk].szSentence1, strlen(Talk[m_idTalk].szSentence1)); dc.TextOut(Rect.left + TILE_WIDTH / 2, Rect.top + TILE_HEIGHT / 2 + nFontSize + 8, Talk[m_idTalk].szSentence2, strlen(Talk[m_idTalk].szSentence2)); //显示闪烁space CFont SpaceFont; SpaceFont.CreatePointFont(90, "Roman"); dc.SelectObject(&SpaceFont); static bool bChange = true; COLORREF Color = (bChange = !bChange) ? RGB(102, 102, 102) : RGB(155, 155, 155); dc.SetTextColor(Color); dc.SetBkMode(TRANSPARENT); dc.TextOut(Rect.right - TILE_WIDTH, Rect.bottom - 20, "space", 5); /* UINT nLineNo; for(nLineNo = 0; nLineNo < strlen(Talk[m_idTalk].szSentence) / nMaxWord; nLineNo++) { dc.TextOut(Rect.left + TILE_WIDTH + TILE_WIDTH / 2 , Rect.top + TILE_HEIGHT / 2 + nLineNo * nFontSize, Talk[m_idTalk].szSentence + nMaxWord * i, nMaxWord); } dc.TextOut(Rect.left + TILE_WIDTH + TILE_WIDTH / 2 , Rect.top + TILE_HEIGHT / 2, Talk[m_idTalk].szSentence, strlen(Talk[m_idTalk].szSentence) % nMaxWord); dc.TextOut(Rect.right - TILE_WIDTH , Rect.top + TILE_HEIGHT / 2 + (strlen(Talk[m_idTalk].szSentence) / nMaxWord + 1) * nFontSize, Talk[m_idTalk].szSentence, strlen(Talk[m_idTalk].szSentence) % nMaxWord); */ }
void CHideDialog::OnTimer(UINT nIDEvent) { CDC *pDC=GetWindowDC (); if(r==255) { if(g==0) { if(b==255) { b=0; r=0; g=255; }else { b+=5; } } else { g-=25; } }else { r+=15; } CFont font; font.CreatePointFont (100,"宋体"); pDC->SelectObject (&font); pDC->SetTextColor (RGB(r,g,b)); pDC->SetBkMode(TRANSPARENT); CRect winRect; GetWindowRect(&winRect); if(is) { Invalidate (); is=FALSE; } pDC->TextOut (13,9,str); font.DeleteObject (); CFont f; f.CreatePointFont (116,"宋体"); pDC->SelectObject (&f); pDC->SetTextColor (RGB(0,0,255)); pDC->TextOut (5,29,"双击返回"); f.DeleteObject (); pDC->DeleteDC (); CDialog::OnTimer(nIDEvent); }
void ScheduleViewEx::OnDraw(CDC* pDC) { Periods& periods = static_cast<CScheduleApp*>(AfxGetApp())->m_periods; Period& period = periods.GetCurrentPeriod(); CTime startDay = period.m_dateRange.GetStartDate(); startDay = startDay + CTimeSpan(xDelta*GetXOffset(),0,0,0); CTime stopDay = startDay + CTimeSpan(xDelta,0,0,0); Truncate(startDay,period.m_dateRange.GetStartDate(), period.m_dateRange.GetEndDate()); Truncate(stopDay,period.m_dateRange.GetStartDate(), period.m_dateRange.GetEndDate()); int startNurse = yDelta * GetYOffset(); int stopNurse = startNurse + yDelta; CString outputText = ViewOutput(startDay,stopDay, startNurse,stopNurse); CFont tmpcourierFont; if (pDC->m_bPrinting) tmpcourierFont.CreatePointFont(printFontSize,_T("Lucida Console")); else tmpcourierFont.CreatePointFont(viewFontSize,_T("Lucida Console")); LOGFONT logFont; tmpcourierFont.GetLogFont(&logFont); logFont.lfUnderline = 1; CFont courierFont; courierFont.CreateFontIndirect(&logFont); CFont * oldFont; oldFont = pDC->SelectObject(&courierFont); pDC->DrawText(outputText,CRect(250,-250,250,-250),DT_NOCLIP); if (!pDC->m_bPrinting) { CRect rcOut(0,0,0,0); VERIFY(pDC->DrawText(outputText,&rcOut,DT_NOCLIP | DT_CALCRECT)); CSize newSize(rcOut.right*1.1,(rcOut.bottom*-1)*1.1); if (newSize != m_oldSize) { SetScrollSizes(MM_HIENGLISH,newSize); m_oldSize = newSize; } } CFont * tmpFont = pDC->SelectObject(oldFont); ASSERT(tmpFont = &courierFont); }
void CListOptionCtrl::InitListBox() { m_bHighlightOnlyText=m_listBoxEx.GetHighlightOnlyText(); m_clrListBoxBack=m_listBoxEx.GetBkColor(); UpdateData(FALSE); // set image list to be displayed static CImageList imageList; imageList.Create(IDB_IL_LISTBOXCHK,16,0,RGB(192,192,192)); m_listBoxEx.SetImageList(&imageList); // fonts for items static CFont g_fontHeader; VERIFY(g_fontHeader.CreatePointFont(150,_T("Arial"))); static CFont g_fontFamily; VERIFY(g_fontFamily.CreatePointFont(140,_T("Times New Roman"))); // hierarchial items AddItem(_T("Simpsons"),0,0,RGB(0,0,0), _T("Reside in Springfield, USA"),&g_fontHeader); AddItem(_T("Homer"),0,20,RGB(0,0,255),_T("Still has hair"),&g_fontFamily); AddItem(_T("Marge"),0,20,RGB(0,0,255),_T(""),&g_fontFamily); AddItem(_T("Bart"),0,40,RGB(0,128,0),_T(""),&g_fontFamily); AddItem(_T("Lisa"),0,40,RGB(0,128,0),_T(""),&g_fontFamily); AddItem(_T("Maggie"),0,40,RGB(0,128,0),_T(""),&g_fontFamily); AddItem(_T("GrandPa"),0,20,RGB(128,128,128),_T(""),&g_fontFamily); for(int nIndex=0; nIndex<m_listBoxEx.GetCount(); nIndex++) { CFont* pFont=new CFont; m_arrFonts.Add(pFont); } m_listBoxEx.SetCurSel(0); OnSelChangeListBoxEx(); //GetParentFrame()->RecalcLayout(); //ResizeParentToFit(); }
BOOL CDoing::OnInitDialog() { CDialog::OnInitDialog(); LONG lStyle = GetWindowLong(m_grid.m_hWnd, GWL_STYLE); lStyle |= LVS_EDITLABELS; // |= 是位运算,用来给控件添加新属性 SetWindowLong(m_grid, GWL_STYLE, lStyle); // 将新的属性设置回网格控件 // 下面,还将设置网格控件的附加属性 m_grid.SetExtendedStyle(LVS_EX_FLATSB | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES); m_grid.ShowWindow(SW_SHOW); m_grid.InsertColumn(0, "文件名", LVCFMT_LEFT, 100); m_grid.InsertColumn(1, "大小", LVCFMT_LEFT, 100); m_grid.InsertColumn(2, "来源", LVCFMT_LEFT, 60); CFont font; font.CreatePointFont(100,_T("宋体"),NULL); GetDlgItem(IDC_STATIC_DOWN)->SetFont(&font); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void myframe::OnTimer(UINT event) { CFont ff; char hour[10],min[10],sec[10]; SYSTEMTIME sm; GetLocalTime(&sm); _itoa(sm.wHour,hour,10); _itoa(sm.wMinute,min,10); _itoa(sm.wSecond,sec,10); RECT rc; GetClientRect(&rc); ff.CreatePointFont(480,"Arial"); CClientDC dc(this); dc.SetTextColor(RGB(00,200,00)); dc.SetBkColor(RGB(0,0,0)); dc.SelectObject(ff); dc.TextOut(rc.right /2 -200,rc.bottom /2,hour); dc.TextOut(rc.right /2 -50,rc.bottom /2,":"); dc.TextOut(rc.right/2 ,rc.bottom /2,min); dc.TextOut(rc.right /2 +150,rc.bottom /2,":"); dc.TextOut(rc.right/2 +200,rc.bottom /2,sec); }
void CSCBButton::Paint(CDC* pDC) { CRect rc = GetRect(); if (bPushed) pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNSHADOW), ::GetSysColor(COLOR_BTNHIGHLIGHT)); else if (bRaised) pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNHIGHLIGHT), ::GetSysColor(COLOR_BTNSHADOW)); COLORREF clrOldTextColor = pDC->GetTextColor(); pDC->SetTextColor(::GetSysColor(COLOR_BTNTEXT)); int nPrevBkMode = pDC->SetBkMode(TRANSPARENT); CFont font; int ppi = pDC->GetDeviceCaps(LOGPIXELSX); int pointsize = MulDiv(60, 96, ppi); // 6 points at 96 ppi font.CreatePointFont(pointsize, _T("Marlett")); CFont* oldfont = pDC->SelectObject(&font); pDC->TextOut(ptOrg.x + 2, ptOrg.y + 2, CString(_T("r"))); // x-like pDC->SelectObject(oldfont); pDC->SetBkMode(nPrevBkMode); pDC->SetTextColor(clrOldTextColor); }
void CLLKBgReady::OnPaint() { CPaintDC dc(this); // device context for painting dc.BitBlt(0,0,m_infoBmpBgReady.bmWidth,m_infoBmpBgReady.bmHeight,&m_dcMem,0,0,SRCCOPY); CString info; info.Format("%s",c_nick); CFont font; font.CreatePointFont(90,"宋体",&dc); dc.SelectObject(&font); dc.SetTextColor(RGB(255,0,0)); dc.SetBkMode(TRANSPORT_TYPE_CN); dc.TextOut(700,93,info); char strScore[100]; itoa(c_score,strScore,10); info.Format("%s",strScore); dc.TextOut(700,109,info); CString level; if(c_score<100){ level.Format("独眼龙"); } else if(c_score<500){ level.Format("近视眼"); } else if(c_score<1000){ level.Format("三只眼"); } else{ level.Format("火眼金睛"); } dc.TextOut(700,124,level); }
CEGPaneBar::CEGPaneBar(void) { m_curHorzDrag = AfxGetApp()->LoadCursor(AFX_IDC_HSPLITBAR); // sometime fails .. m_curVertDrag = AfxGetApp()->LoadCursor(AFX_IDC_VSPLITBAR); // sometime fails .. m_hPane = NULL; m_bDragging = FALSE; m_pszCaption = NULL; m_fntCaption = NULL; HFONT hFont = (HFONT) GetStockObject( DEFAULT_GUI_FONT ); if ( NULL != hFont ) { LOGFONT lf; if ( GetObject( hFont, sizeof( LOGFONT), &lf ) ) { // lf.lfWeight = FW_BOLD; m_fntCaption = ::CreateFontIndirect( &lf ); } } CFont font; HDC hdc = ::GetDC( NULL ); int ppi = ::GetDeviceCaps( hdc, LOGPIXELSX); ::ReleaseDC ( NULL, hdc ); int pointsize = MulDiv( 80 , 96, ppi); // 6 points at 96 ppi font.CreatePointFont( pointsize , _T("Marlett")); m_fntXButton = (HFONT) font.Detach(); m_bClosePressed = FALSE; m_bCloseHover = FALSE; m_bActive = FALSE; }
BOOL CKeysDlg::OnInitDialog() { CDialog::OnInitDialog(); m_wndKeyEdit.SetBackColor(RGB(255, 255, 255)); CFont font; font.CreatePointFont(150, _T(""), NULL); m_wndKeyEdit.SetFont(&font); CString str = _T("It has at least two different answers.\r\n\r\n"); for(int i = 0;i < 9;i ++) { CString tempStr; for(int j = 0;j < 9;j ++) { tempStr.Format(_T("%d "), m_num1[i][j]); str += tempStr; } str += _T(" "); for(int j = 0;j < 9;j ++) { tempStr.Format(_T("%d "), m_num2[i][j]); str += tempStr; } str += _T("\r\n"); } m_wndKeyEdit.SetWindowText(str); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
CSize CChartAxisLabel::GetSize(CDC *pDC) const { CSize LabelSize; LabelSize.cx = 0; LabelSize.cy = 0; if (!m_bIsVisible) return LabelSize; if (!pDC->GetSafeHdc()) return LabelSize; if (m_strLabelText == _T("")) return LabelSize; COLORREF OldColor = pDC->SetTextColor(m_ObjectColor); CFont NewFont; CFont* pOldFont; NewFont.CreatePointFont(m_iFontSize, (LPCTSTR)m_strFontName.c_str(),pDC); pOldFont = pDC->SelectObject(&NewFont); LabelSize = pDC->GetTextExtent(m_strLabelText.c_str()); LabelSize.cx += 4; LabelSize.cy += 4; if (!m_bIsHorizontal) { int Width = LabelSize.cy; int Height = LabelSize.cx; LabelSize.cx = Width; LabelSize.cy = Height; } pDC->SelectObject(pOldFont); DeleteObject(NewFont); pDC->SetTextColor(OldColor); return LabelSize; }
void CControlTestDialog::OnBnClickedButtonTestStaticText() { this->ResetTest(); CStaticEx *pSt = new CStaticEx(); CRect rcClient; this->GetClientRect( rcClient ); const CRect rcSt( 0,0, rcClient.Width(), 50 ); BOOL bResult = pSt->Create( _T( "红色文字宋体12px透明背景左对齐" ), SS_LEFT | WS_VISIBLE | WS_CHILD, rcSt, this ); _ASSERT( bResult ); pSt->ShowWindow( SW_SHOW ); m_pTestWnd = pSt; pSt->SetTextColor( RGB( 128, 10, 10 ), RGB( 128, 128, 128 ), TRUE ); CFont font; BOOL bSuccess = font.CreatePointFont( 12, _T( "宋体" ) ); _ASSERT( bSuccess ); pSt->SetFont( &font ); pSt->UpdateBk(); // TODO: 在此添加控件通知处理程序代码 }
int CListOptionCtrl::AddItem(LPCTSTR lpszText) { //AfxMessageBox(_T("AddItem1")); static CFont g_fontNormal; VERIFY(g_fontNormal.CreatePointFont(120,_T("Arial"))); int nIndex= m_listBoxEx.AddString(lpszText); ASSERT(nIndex!=LB_ERR); //AfxMessageBox(_T("AddItem2")); m_listBoxEx.SetItemImageIndex(nIndex,0); m_listBoxEx.SetItemIndent(nIndex,0); m_listBoxEx.SetItemTextColor(nIndex, RGB(0,0,0)); m_listBoxEx.SetItemTooltipText(nIndex,lpszText); m_listBoxEx.SetItemFont(nIndex, &g_fontNormal); return nIndex; }
CSize CChartAxis::GetLargestTick(CDC* pDC) { CFont NewFont; NewFont.CreatePointFont(m_nFontSize,m_strFontName.c_str(),pDC); CFont* pOldFont = pDC->SelectObject(&NewFont); CSize MaxSize(0,0); if (m_MaxValue == m_MinValue) { TChartString strLabel = GetTickLabel(m_MinValue); MaxSize = pDC->GetTextExtent(strLabel.c_str(),strLabel.size()); } else { double TickValue = GetFirstTickValue(); do { if (IsLabelOnAxis(TickValue)) { TChartString strLabel = GetTickLabel(TickValue); CSize TextSize = pDC->GetTextExtent(strLabel.c_str(),strLabel.size()); if (TextSize.cy > MaxSize.cy) MaxSize.cy = TextSize.cy; if (TextSize.cx > MaxSize.cx) MaxSize.cx = TextSize.cx; } } while (GetNextTickValue(TickValue, TickValue)); } pDC->SelectObject(pOldFont); NewFont.DeleteObject(); return MaxSize; }
BOOL CDlgTabShopping::OnInitDialog() { CDialogEx::OnInitDialog(); SetBackgroundColor(DialogBackgroundColor,TRUE); // TODO: 在此添加额外的初始化 GetDlgItem(IDC_TAB)->ShowWindow(SW_HIDE); SetTabsPosition(); CFont font; font.CreatePointFont(100,_T("宋体")); m_TabCtrl.SetFont(&font); m_TabCtrl.SetFontSelect(&font); // //m_TabCtrl.SetCursor(IDC_CURSOR1); m_TabCtrl.RemoveTabEnable(true); // //m_TabCtrl.SetNotifyManager(this); // m_TabCtrl.InstallStyle(&m_TabCtrl.styleVS2008_client_blue); // install style. m_TabCtrl.Add(m_DlgShopping,_T("购物"),0); m_TabCtrl.Add(m_DlgSubExpressage,_T("快递"),0); m_TabCtrl.ShowBorder(FALSE); m_TabCtrl.Update(); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }
void CPlot::DrawLegend( CDC* pDC,CRect &rectZone) { if (!pDC->GetSafeHdc()){ return; } int lineLength = 30; // 图例线长 int textWidht = 20; // 图例字体宽度 int unitGap = 10; // 两个图例间的距离 int xCoord = rectZone.left;// 当前X轴坐标 // 遍历所有曲线 for (int i=0;i<validLinesCount && xCoord<rectZone.right;i++) { CPen pen(m_linePtrArray[i]->getLineType(),m_linePtrArray[i]->getLineWidth(),m_linePtrArray[i]->getLineColor()); CPen *oldPen = pDC->SelectObject(&pen); pDC->MoveTo(xCoord,rectZone.top+rectZone.Height()/2); xCoord += lineLength; pDC->LineTo(xCoord,rectZone.top+rectZone.Height()/2); xCoord += 5;// 向右移动5个像素点 pDC->SelectObject(oldPen); CFont font; font.CreatePointFont(90,_T("Courier New"),pDC); CFont *oldFont = pDC->SelectObject(&font); pDC->SetTextColor(m_linePtrArray[i]->getLineColor()); pDC->DrawText(m_linePtrArray[i]->getLineName(), CRect(xCoord,rectZone.top,xCoord+textWidht,rectZone.bottom), DT_CENTER); xCoord += (textWidht+unitGap); pDC->SelectObject(oldFont); } }
// Draw graph title; size is proportionate to width. void MyGraph::DrawTitle(CDC& dc) { VALIDATE; ASSERT_VALID(&dc); // Create the title font. CFont fontTitle; VERIFY(fontTitle.CreatePointFont(max(m_rcGraph.Width() / TITLE_DIVISOR, MIN_FONT_SIZE), _T("Arial"), &dc)); CFont* pFontOld = dc.SelectObject(&fontTitle); ASSERT_VALID(pFontOld); // Draw the title. m_rcTitle.SetRect(GAP_PIXELS, GAP_PIXELS, m_rcGraph.Width() + GAP_PIXELS, m_rcGraph.Height() + GAP_PIXELS); dc.DrawText(m_sTitle, m_rcTitle, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_TOP | DT_CALCRECT); m_rcTitle.right = m_rcGraph.Width() + GAP_PIXELS; dc.DrawText(m_sTitle, m_rcTitle, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_TOP); VERIFY(dc.SelectObject(pFontOld)); fontTitle.DeleteObject(); }
/************* * DESCRIPTION: constructor * INPUT: * OUTPUT: - *************/ CMaterial::CMaterial(CDC *pDC, SURFACE *surf) { CFont font; ASSERT(surf != NULL); pSurface = surf; Bitmap.CreateCompatibleBitmap(pDC, MATWIDTH, MATTOTALHEIGHT); MemDC.CreateCompatibleDC(pDC); MemDC.SelectObject(&Bitmap); MemDC.SetViewportOrg(0, 0); MemDC.SetWindowOrg(0, 0); MemDC.SetMapMode(MM_TEXT); if (font.CreatePointFont(90, "Helv")) MemDC.SelectObject(&font); MemDC.SelectPalette(pPal, TRUE); MemDC.RealizePalette(); LOGBRUSH logbrush; CBrush::FromHandle((HBRUSH)GetStockObject(LTGRAY_BRUSH))->GetLogBrush(&logbrush); MemDC.SetBkColor(logbrush.lbColor); bThread = FALSE; MaterialStruct.hThread = NULL; Update(); return; }
// ********************************************************************* // CreateFont() // ********************************************************************* CFont* GdiLabelDrawer::CreateFont(CLabelOptions* options, long fontSize, double scaleFactor) { CFont* fnt = new CFont(); CString s(options->fontName); fnt->CreatePointFont(fontSize * 10, s); LOGFONT lf; fnt->GetLogFont(&lf); if (scaleFactor != 1.0) { lf.lfWidth = long((double)lf.lfWidth * scaleFactor); lf.lfHeight = long((double)lf.lfHeight * scaleFactor); } if (abs(lf.lfHeight) < 4) // changed 1 to 4; there is no way to read labels smaller than 4, but they slow down the performance { fnt->DeleteObject(); delete fnt; return NULL; } lf.lfItalic = options->fontStyle & fstItalic; lf.lfUnderline = options->fontStyle & fstUnderline; lf.lfStrikeOut = options->fontStyle & fstStrikeout; lf.lfWeight = options->fontStyle & fstBold ? FW_BOLD : 0; fnt->DeleteObject(); fnt->CreateFontIndirectA(&lf); return fnt; }
// VerConfig 消息处理程序 BOOL VerConfig::OnInitDialog() { CDialog::OnInitDialog(); CStatic *hStatic; CString strout; static CFont font; font.CreatePointFont(100, font_list[font_index]); hStatic = (CStatic*)GetDlgItem(IDC_STATIC_VERCFG); strout.Format(""); strout.Format(strout + "SAVE_TICK %d\n", SAVE_TICK); strout.Format(strout + "CONFIG_MAX_AUTO_MAIL %d\n", CONFIG_MAX_AUTO_MAIL); strout.Format(strout + "PROGRAM_VERSION %s\n", PROGRAM_VERSION); strout.Format(strout + "EMAIL_TITLE %s\n", EMAIL_TITLE); strout.Format(strout + "PROGRAM_TITLE %s\n", PROGRAM_TITLE); hStatic->SetFont(&font); hStatic->SetWindowText(strout); SetWindowText("软件配置信息"); return true; }
void CMLTView::OnDraw(CDC* pDC) { CConfigToolDoc* pDoc = CConfigTool::GetConfigToolDoc(); if (pDoc == NULL) // no document so nothing to draw return; // clear the lists of region and section rectangles used for hit testing listRegionRect.RemoveAll (); listSectionRect.RemoveAll (); // setup background mode int nOldBkMode = pDC->SetBkMode (TRANSPARENT); // setup font CFont fntName; if (!fntName.CreatePointFont (80, _T("MS Sans Serif"), pDC)) return; CFont * pOldFont = pDC->SelectObject (&fntName); // determine max unit count for any region mem_map * pMemoryMap = &CConfigTool::GetConfigToolDoc()->MemoryMap; // calculate the unit scaling for DISPLAY_MODE 1 UINT uPixelsPerUnit = UNIT_WIDTH_MIN; RECT rectClientRect; if (m_uUnitCountMax != 0) // if there is something to draw { GetClientRect (&rectClientRect); uPixelsPerUnit = __max ((m_uClientWidth - HORIZ_BORDER * 2) / m_uUnitCountMax, UNIT_WIDTH_MIN); m_uViewWidth = uPixelsPerUnit * m_uUnitCountMax + HORIZ_BORDER * 2; } // draw the regions UINT uRegion = 0; UINT uUnitCount; list <mem_region>::iterator region; for (region = pMemoryMap->region_list.begin (); region != pMemoryMap->region_list.end (); ++region) { uUnitCount = 0; for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view) uUnitCount += (section_view->section == NULL ? 1 : UNITS_PER_SECTION); if (DISPLAY_MODE == 1) DrawRegion (pDC, uRegion++, uUnitCount, uPixelsPerUnit, region); else // DISPLAY_MODE == 2 DrawRegion (pDC, uRegion++, uUnitCount, (rectClientRect.right - HORIZ_BORDER * 2) / uUnitCount, region); } pDC->SelectObject (pOldFont); pDC->SetBkMode (nOldBkMode); }
BOOL WarningDlg::OnEraseBkgnd(CDC* pDC) { CRect rctClient; GetClientRect(rctClient); CDC dcMem; dcMem.CreateCompatibleDC(pDC); CBitmap m_bmp; m_bmp.LoadBitmap(IDB_BACK2); BITMAP bitmap; m_bmp.GetBitmap(&bitmap); CBitmap *pbmpOld = dcMem.SelectObject(&m_bmp); CString buff; pDC->StretchBlt(0, 0, rctClient.Width(), rctClient.Height(), &dcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);//绘制背景 /*输出标题 文字*/ CFont font; font.CreatePointFont(120, L"微软雅黑"); CDC*pdc = GetDC(); pdc->SetBkMode(TRANSPARENT); pdc->SelectObject(&font); pdc->SetTextColor(RGB(255, 255, 255)); //pdc->TextOutW(20, 7, L"违规事件"); //输出信息 pdc->TextOutW(20, 20, g_EventStrInfo.szCaption); pdc->TextOutW(20, 50, g_EventStrInfo.szType); pdc->SetTextColor(RGB(0, 0, 200)); pdc->TextOutW(20, 97, g_EventStrInfo.szName); pdc->SetTextColor(RGB(0, 0, 0)); pdc->TextOutW(20, 127, g_EventStrInfo.szDescribe); int len = g_EventStrInfo.szPath.GetLength(); int line = 50; if (len > line) { pdc->TextOutW(20, 157, g_EventStrInfo.szPath.Mid(0, line)); if (len > 2 * line) { pdc->TextOutW(20, 177, g_EventStrInfo.szPath.Mid(line, line-4)+L" ...."); } else { pdc->TextOutW(20, 177, g_EventStrInfo.szPath.Mid(line, len - line)); } } else { pdc->TextOutW(20, 157, g_EventStrInfo.szPath); } ReleaseDC(pdc); /**/ return true; }
void mainStrShowDlg::setText(CString str) { m_strMainString = str ; CFont *lpfont = new CFont ; lpfont->CreatePointFont(140,_T("楷体_GB2312"),NULL ); //m_editStr.SetFont(&font); m_editStr.SetFont( lpfont ) ; UpdateData(FALSE); }
void shp_text::draw(CDC *dc) { CFont font; font.CreatePointFont(font_size_, "���ו", NULL); dc->SelectObject(&font); dc->SetBkMode(TRANSPARENT); dc->SetTextColor(font_color_); dc->DrawText(str_text_.c_str(), &rect_, style_); }
void CPlot::DrawTile( CDC* pDC,CRect &rectZone) { if (!pDC->GetSafeHdc()){ return; } CFont font; font.CreatePointFont(90,_T("Courier New"),pDC); CFont *oldFont = pDC->SelectObject(&font); pDC->SetTextColor(RGB(255,255,0)); pDC->DrawText(_T("BLT Temperature"),rectZone,DT_CENTER); pDC->SelectObject(oldFont); }
void CMyHistorgram::DrawLine(vector<CPoint> pointList, int lineStyle, int lineWidth, COLOR color) { CPen newPen; newPen.CreatePen(lineStyle, lineWidth, color); m_pDC->SelectObject(&newPen); CPoint point; int mode; if (pointList.size()) { point.x = (pointList[0].x - xMinValue) / xUnit; point.y = m_rect.bottom - (pointList[0].y - yMinValue) / yUnit; m_pDC->MoveTo(point); mode = pointList[0].y; m_modeIndex = pointList[0].x; } for (int i = 1; i < pointList.size(); i++) { point.x = (pointList[i].x - xMinValue) / xUnit; point.y = m_rect.bottom - (pointList[i].y - yMinValue) / yUnit; m_pDC->LineTo(point); if (pointList[i].y>mode) { mode = pointList[i].y; m_modeIndex = pointList[i].x; } } if (m_bShowEXDX) { if (pointList.size()) { //m_pDC->MoveTo((m_modeIndex - xMinValue) / xUnit, m_rect.bottom); //m_pDC->LineTo((m_modeIndex - xMinValue) / xUnit, m_rect.top); m_meanValue = GetMeanValue(pointList); m_variance = GetVariance(pointList, m_meanValue); CFont font; font.CreatePointFont(160, _T("宋体")); CFont*def_font = m_pDC->SelectObject(&font); //选择该字体进入PDC CString tempStr; tempStr.Format(_T("EX = %.2f"), m_meanValue); m_pDC->TextOut(m_rect.left + 40, m_rect.top + 20, tempStr); tempStr.Format(_T("DX = %.2f"), m_variance); m_pDC->TextOut(m_rect.left + 40, m_rect.top + 60, tempStr); m_pDC->SelectObject(def_font);//恢复PDC的缺省字体 font.DeleteObject();//释放font对象 } } }
CSize CChartLegend::GetSize(CDC* pDC) const { CSize LegendSize; CSize TextSize; if (!m_bIsVisible) { LegendSize.cx = LegendSize.cy = 0; return LegendSize; } CFont* pOldFont; CFont NewFont; NewFont.CreatePointFont(m_iFontSize, (LPCTSTR)m_strFontName.c_str(),pDC); pOldFont = pDC->SelectObject(&NewFont); int Height = 4; //Upper space int Width = 0; int MaxTextWidth = 0; size_t SeriesCount = m_pParent->GetSeriesCount(); int Drawn = 0; for (size_t i=0;i<SeriesCount;i++) { CChartSerie* pSerie = m_pParent->GetSerie(i); if ( (pSerie->GetName() == _T("")) || !pSerie->IsVisible() ) continue; Drawn++; CSize BitmapSize =pSerie->GetLegendSize(); TextSize = pDC->GetTextExtent(pSerie->GetName().c_str()); if (TextSize.cy>BitmapSize.cy) Height += TextSize.cy + 2; else Height += BitmapSize.cy + 2; if ( (TextSize.cx + BitmapSize.cx + 6)> MaxTextWidth) MaxTextWidth = TextSize.cx + BitmapSize.cx + 6; } if (!Drawn) { LegendSize.cx = LegendSize.cy = 0; return LegendSize; } Width += MaxTextWidth + 6; LegendSize.cx = Width; LegendSize.cy = Height+2; pDC->SelectObject(pOldFont); DeleteObject(NewFont); return LegendSize; }
void CMy20140903View::OnDraw(CDC* pDC) { CMy20140903Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here CFont font; font.CreatePointFont(300,"宋体"); CFont *pOldFont; pOldFont=pDC->SelectObject(&font); CString strTemp; strTemp = "职业:"; switch(m_iOccupation) { case 0: strTemp += "程序员"; break; case 1: strTemp += "系统工程师"; break; case 2: strTemp += "项目经理"; break; default: break; } pDC->TextOut(0, 0, strTemp); TEXTMETRIC tm; pDC->GetTextMetrics(&tm); strTemp = "工作地点:"; strTemp += m_strWorkAddr; pDC->TextOut(0, tm.tmHeight, strTemp); strTemp = "兴趣爱好:"; if(m_bLike[0]) strTemp += "足球 "; if(m_bLike[1]) strTemp += "篮球 "; if(m_bLike[2]) strTemp += "排球 "; if(m_bLike[3]) strTemp += "游泳"; pDC->TextOut(0, tm.tmHeight * 2, strTemp); strTemp = "薪资水平:"; strTemp += m_strSalary; pDC->TextOut(0, tm.tmHeight * 3, strTemp); pDC->SelectObject(pOldFont); }
void CGameDlg::ShowScore(void) { CDC* pDC = GetDC(); CFont font; font.CreatePointFont(150, _T("Courier New")); CFont* oldFont = pDC->SelectObject(&font); pDC->SetTextColor(RGB(0,0,255)); pDC->SetBkColor(RGB(255, 255, 255)); CString stringScore; stringScore.Format(_T("Score: %4d"),Score); CSize size = pDC->GetTextExtent(stringScore, stringScore.GetLength()); pDC->TextOutW(500,455, stringScore); }