本文整理汇总了C++中CFont::CreatePointFont方法的典型用法代码示例。如果您正苦于以下问题:C++ CFont::CreatePointFont方法的具体用法?C++ CFont::CreatePointFont怎么用?C++ CFont::CreatePointFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFont
的用法示例。
在下文中一共展示了CFont::CreatePointFont方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dc
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()
}
示例2: OnDraw
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);
*/
}
示例3: OnTimer
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);
}
示例4: OnDraw
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);
}
示例5: InitListBox
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();
}
示例6: OnInitDialog
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
}
示例7: OnTimer
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);
}
示例8: Paint
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);
}
示例9: OnPaint
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);
}
示例10: AfxGetApp
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;
}
示例11: OnInitDialog
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
}
示例12: GetSize
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;
}
示例13: OnBnClickedButtonTestStaticText
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: 在此添加控件通知处理程序代码
}
示例14: AddItem
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;
}
示例15: GetLargestTick
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;
}