本文整理汇总了C++中CFont::CreateFontIndirect方法的典型用法代码示例。如果您正苦于以下问题:C++ CFont::CreateFontIndirect方法的具体用法?C++ CFont::CreateFontIndirect怎么用?C++ CFont::CreateFontIndirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFont
的用法示例。
在下文中一共展示了CFont::CreateFontIndirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DisplayMessages
void KSMsgDrawer::DisplayMessages(CDC * pDC,const CRect & client)
{
if(!m_showMessage)
return;
// 设置字体
LOGFONT lf;
memset(&lf,0,sizeof lf);
lf.lfCharSet = GB2312_CHARSET;
strcpy(lf.lfFaceName,m_fontName);
lf.lfHeight = m_fontSize;
lf.lfWeight = FW_BOLD;
CFont font;
CFont *oldFont;
font.CreateFontIndirect(&lf);
oldFont = pDC->SelectObject(&font);
// 如果只有一行就居中
int line_top = (m_displayMsgList.size() == 1) ? client.Height() / 2 :
client.Height() / 3;
int last_line = 1;
for(cstr_vector::iterator i = m_displayMsgList.begin();
i != m_displayMsgList.end();++i)
{
cstring_msg msg = (*i).second;
int lineno = msg.GetLineno();
if( lineno <= 0)
continue;
CString msg_str = msg.GetMsg();
if(msg.GetSizeOffset() != 0)
{
font.DeleteObject();
lf.lfHeight = m_fontSize + msg.GetSizeOffset();
font.CreateFontIndirect(&lf);
pDC->SelectObject(&font);
}
CSize size = pDC->GetTextExtent(msg_str);
RECT textRect;
textRect.left = (client.Width() - size.cx) / 2;
if(textRect.left < 1)
textRect.left = 1;
textRect.right = textRect.left + size.cx;
if (textRect.right >= client.right )
textRect.right = client.right - 1;
textRect.top = line_top + (lineno - last_line) * size.cy;
textRect.bottom = client.bottom;
pDC->DrawText(msg_str,&textRect,DT_CENTER|DT_SINGLELINE);
last_line = msg.GetLineno();
line_top = textRect.top + size.cy;
}
pDC->SelectObject(oldFont);
}
示例2: OnPaint
void CSplashScreen::OnPaint()
{
CPaintDC dc(this); // device context for painting
if (m_imgSplash.GetSafeHandle())
{
CDC dcMem;
if (dcMem.CreateCompatibleDC(&dc))
{
CBitmap* pOldBM = dcMem.SelectObject(&m_imgSplash);
BITMAP BM;
m_imgSplash.GetBitmap(&BM);
dc.BitBlt(0, 0, BM.bmWidth, BM.bmHeight, &dcMem, 0, 0, SRCCOPY);
if (pOldBM)
dcMem.SelectObject(pOldBM);
CRect rc(0, (int)(BM.bmHeight * 0.65), BM.bmWidth, BM.bmHeight);
dc.FillSolidRect(rc.left+1, rc.top+1, rc.Width()-2, rc.Height()-2, RGB(255,255,255));
LOGFONT lf = {0};
lf.lfHeight = 30;
lf.lfWeight = FW_BOLD;
lf.lfQuality = afxIsWin95() ? NONANTIALIASED_QUALITY : ANTIALIASED_QUALITY;
_tcscpy(lf.lfFaceName, _T("Arial"));
CFont font;
font.CreateFontIndirect(&lf);
CFont* pOldFont = dc.SelectObject(&font);
CString strAppVersion(_T("eMule ") + theApp.m_strCurVersionLong);
rc.top += dc.DrawText(strAppVersion, &rc, DT_CENTER | DT_NOPREFIX);
if (pOldFont)
dc.SelectObject(pOldFont);
font.DeleteObject();
rc.top += 8;
lf.lfHeight = 14;
lf.lfWeight = FW_NORMAL;
lf.lfQuality = afxIsWin95() ? NONANTIALIASED_QUALITY : ANTIALIASED_QUALITY;
_tcscpy(lf.lfFaceName, _T("Arial"));
font.CreateFontIndirect(&lf);
pOldFont = dc.SelectObject(&font);
dc.DrawText(_T("Copyright (C) 2002-2015 Merkur"), &rc, DT_CENTER | DT_NOPREFIX);
if (pOldFont)
dc.SelectObject(pOldFont);
font.DeleteObject();
}
}
}
示例3: Initialise
/*
* Method preamble ************************************************************
*
* CLASS: TFXDataTip
* NAME: Initialise
*
* DESCRIPTION: This method initialise the DataTip class. It creates the
* default font used for DataTips, the brush used to paint
* windows background, and registers the window class.
*
* If there is currently no hook procedure instaklled for
* the class it alos installs a keyboard hook procedure.
*
* PARAMETERS: none
*
* RETURN TYPE: void
*
******************************************************************************
* REVISION HISTORY
*
******************************************************************************
*/
void TFXDataTip::Initialise( )
{
if (_font.GetSafeHandle( ) == NULL)
{
// create the default tip font
LOGFONT lFont;
GetObject(GetStockObject(ANSI_FIXED_FONT), sizeof lFont, &lFont);
_font.CreateFontIndirect(&lFont);
// create the other GDI objects
//_brush = new CBrush(::GetSysColor(COLOR_INFOBK));
_brush = new CBrush( RGB(32,32,32) );
}
// register the window class
RegisterWnd( );
// install the keyboard hook procedure
if (_hookProc == NULL)
{
_hookProc = ::SetWindowsHookEx(WH_KEYBOARD,
(HOOKPROC)KeyboardHookCallback,
NULL,
::GetCurrentThreadId( ));
}
}
示例4:
/*============================================================================*/
void MyFontDialog::
SetFontIndirect(const LOGFONT& lf) /*
Set the current font to have the characteristics contained in the
supplied LOGFONT structure lf. Copy the face name into the font choice
style name.
*-----------------------------------------------------------------------------*/
{
// convert lf to a CFont
CFont hf;
hf.CreateFontIndirect(&lf);
// if it worked, put it in this object
if(hf)
{
DeleteObject(m_Font);
m_Font = hf;
}
else
{
::MessageBox(NULL, _T("Font creation error."),
_T("Error"), MB_OK | MB_ICONEXCLAMATION |
MB_TASKMODAL);
}
}
示例5: Draw
////////////////////////////////////////////////////////////////////
// Public functions
//
void CDrawField::Draw( int page, CDC* dc )
/* ============================================================
Function : CDrawField::Draw
Description : Draws this object.
Access : Public
Return : void
Parameters : int page - Current page
CDC* dc - CDC to draw to
Usage : Called by the generator to draw the object.
============================================================*/
{
CString title = GetTitle();
CDoubleRect rect = GetPosition();
CUnitConversion::InchesToPixels( rect );
CRect r( static_cast< int >( rect.left ), static_cast< int >( rect.top ), static_cast< int >( rect.right ), static_cast< int >( rect.bottom ) );
CUnitConversion::AdjustPixelsToPaper( dc, r );
LOGFONT lf;
ZeroMemory( &lf, sizeof( lf ) );
lstrcpy( lf.lfFaceName, GetFontName() );
lf.lfHeight = CUnitConversion::PointsToPixels( static_cast< double >( GetFontSize() ) / 10.0 );
lf.lfItalic = static_cast< BYTE >( GetFontItalic() );
lf.lfUnderline = static_cast< BYTE >( GetFontUnderline() );
lf.lfStrikeOut = static_cast< BYTE >( GetFontStrikeout() );
lf.lfCharSet = static_cast< BYTE >( GetFontCharset() );
if( GetFontBold() )
lf.lfWeight = FW_BOLD;
else
lf.lfWeight = FW_NORMAL;
if( IsBold( title ) )
lf.lfWeight = FW_BOLD;
if( IsItalic( title ) )
lf.lfItalic = TRUE;
CFont font;
font.CreateFontIndirect( &lf );
dc->SelectObject( &font );
int color = dc->SetTextColor( GetFontColor() );
int mode = dc->SetBkMode( TRANSPARENT );
int justification = GetJustification();
ReplaceFields( page, title );
dc->DrawText( title, r, DT_NOPREFIX | DT_WORDBREAK | justification );
dc->SetBkMode( mode );
dc->SetTextColor( color );
dc->SelectStockObject( ANSI_VAR_FONT );
}
示例6: Draw
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 );
}
示例7: paintDialogHeader
void paintDialogHeader(CDC* pDC, const CString &strTitle) {
int nWidth = pDC->GetDeviceCaps(HORZRES);
const int nHeaderHeight = 24;
// paint title
CFont *pCurrentFont = pDC->GetCurrentFont();
LOGFONT lf;
pCurrentFont->GetLogFont(&lf);
lf.lfWeight = FW_BOLD;
CFont newFont;
newFont.CreateFontIndirect(&lf);
CFont *pSave = pDC->SelectObject(&newFont);
//pDC->SetBkColor(RGB(100,100,100));
pDC->SetBkColor(::GetSysColor(COLOR_STATIC));
pDC->SetTextColor(RGB(0, 0, 156));
pDC->DrawText(strTitle, CRect(8, 0, nWidth, nHeaderHeight), DT_VCENTER | DT_SINGLELINE);
pDC->SelectObject(pSave);
// paint line
CPen blackPen(PS_SOLID, 1, RGB(0,0,0));
CPen *pOldPen = pDC->SelectObject(&blackPen);
pDC->MoveTo(0, nHeaderHeight);
pDC->LineTo(nWidth, nHeaderHeight);
pDC->SelectObject(pOldPen);
}
示例8: DrawVerticalText
void CGradientStatic::DrawVerticalText(CRect *pRect)
{
CFont *pOldFont = NULL;;
LOGFONT lfFont;
if(m_cfFont.GetSafeHandle())
{
m_cfFont.GetLogFont(&lfFont);
}
else
{
CFont *pFont = GetFont();
pFont->GetLogFont(&lfFont);
_tcscpy(lfFont.lfFaceName, _T("Arial")); // some fonts won't turn :(
}
lfFont.lfEscapement = 900;
CFont Font;
Font.CreateFontIndirect(&lfFont);
pOldFont = m_Mem.dc.SelectObject(&Font);
CString strText;
GetWindowText(strText);
m_Mem.dc.SetTextColor(m_crTextColor);
m_Mem.dc.SetBkColor(TRANSPARENT);
CRect rText = pRect;
rText.bottom -= 5;
DrawRotatedText(m_Mem.dc.m_hDC, strText, rText, 90);
m_Mem.dc.SelectObject(pOldFont);
}
示例9: Draw
//--------------------------------------------------------------------------
// 그리기 함수
//--------------------------------------------------------------------------
void GText::Draw(CDC* pDC)
{
CFont font;
font.CreateFontIndirect(&m_sLogFont); //폰트 생성
CFont *oldFont = pDC->SelectObject(&font); //폰트 지정
COLORREF oldTextColor, oldBkColor;
oldTextColor = pDC->SetTextColor(m_sLineColor); //글자 색 지정
oldBkColor = pDC->SetBkColor(m_sBgColor); //배경 색 지정
int oldBkMode;
if(m_bsTransparent == TRUE) //배경 투명일 경우
oldBkMode = pDC->SetBkMode(TRANSPARENT); //투명 배경
else //투명이 아닐 경우
oldBkMode = pDC->SetBkMode(OPAQUE); //지정한 배경색의 배경
CSize textSize = pDC->GetTextExtent(m_sArrayString.GetData(), m_sArrayString.GetSize()); //텍스트가 그려질 영역의 크기를 구함
//글자 끝 위치 지정
m_sEndPoint.x = m_sStartPoint.x + textSize.cx;
m_sEndPoint.y = m_sStartPoint.y + textSize.cy;
CRect textRect(m_sStartPoint.x, m_sStartPoint.y, m_sEndPoint.x, m_sEndPoint.y); //텍스트가 그려질 rect
pDC->DrawText(m_sArrayString.GetData(), m_sArrayString.GetSize(), &textRect, DT_LEFT | DT_SINGLELINE); //글자 쓰기
//이전 설정으로 되돌리기
pDC->SetTextColor(oldTextColor); //이전 텍스트 컬러로 되돌리기
pDC->SetBkColor(oldBkColor); //이전 백그라운드 컬러로 되돌리기
pDC->SetBkMode(oldBkMode); //이전 백그라운드 모드로 되돌리기
pDC->SelectObject(oldFont); //옛날 폰트로 되돌리기
}
示例10: Draw
void CDiagramButton::Draw( CDC* dc, CRect rect )
/* ============================================================
Function : CDiagramButton::Draw
Description : Draws the "control"
Return : void
Parameters : CDC* dc - CDC to draw to
CRect rect - Total object rect (zoomed)
Usage :
============================================================*/
{
CStdGrfx::drawframed3dBox( dc, rect );
LOGFONT lf;
CFont font;
GetFont( lf );
// MS Sans Serif will not scale below 8 pts.
if( GetZoom() < 1 )
lstrcpy( lf.lfFaceName, _T( "Arial" ) );
font.CreateFontIndirect( &lf );
dc->SelectObject( &font );
dc->SetBkMode( TRANSPARENT );
dc->DrawText( GetTitle(), rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
dc->SelectStockObject( ANSI_VAR_FONT );
}
示例11: OnInitDialog
/* Called when the dialog is loaded, in response to the WM_INITDIALOG message.
*/
BOOL CSubmitOrderDialog::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// Create warning font and display text
CFont* pFont = new CFont;
CPaintDC dc(this);
LOGFONT lf = { 0 };
lf.lfHeight = -MulDiv(8, GetDeviceCaps(dc.GetSafeHdc(), LOGPIXELSY), 40);
lf.lfWeight = FW_BOLD;
strcpy_s(lf.lfFaceName, "Microsoft Sans Serif");
pFont->CreateFontIndirect(&lf);
GetDlgItem(IDC_WARNING)->SetFont(pFont);
// Initialize the TTDropHandler event sink.
m_pDropHandler = new CDropHandlerSink();
// Set this class to receive the XTAPI TTDropHandler events.
m_pDropHandler->SetCallback(this);
// Register the application window to receive drag and drop.
m_pDropHandler->Obj()->raw_RegisterDropWindow((int)m_hWnd);
m_OrderTypeCombo.SetCurSel(0);
// Delete the font object
delete pFont;
pFont = NULL;
return TRUE; // return TRUE unless you set the focus to a control
}
示例12: RenderSample
void CConfigDlg::RenderSample()
{
CFont font;
CHARFORMAT2 cf;
long s1,s2;
font.CreateFontIndirect(&m_sDComCfgTmp.m_logfont);
m_sampleText.SetFont(&font);
memset(&cf, 0, sizeof(cf));
cf.cbSize = sizeof(cf);
cf.crTextColor = m_sDComCfgTmp.m_crFore;
cf.crBackColor = m_sDComCfgTmp.m_crBack;
cf.dwMask = CFM_COLOR | CFM_BACKCOLOR;
m_sampleText.SetSel(0, -1);
m_sampleText.ReplaceSel("Normal");
m_sampleText.SetSel(0, -1);
m_sampleText.SetSelectionCharFormat(cf);
m_sampleText.GetSel(s1, s2);
cf.crTextColor = SCROLLBUFF_MAKE_BOLD(m_sDComCfgTmp.m_crFore);
m_sampleText.SetSel(s2, -1);
m_sampleText.ReplaceSel(" Bold");
m_sampleText.SetSel(s2, -1);
m_sampleText.SetSelectionCharFormat(cf);
m_sampleText.SetSel(-1, -1);
m_sampleText.SetBackgroundColor(FALSE, m_sDComCfgTmp.m_crBack);
font.DeleteObject();
}
示例13: OnBtnFont
void CPageFormatDlg::OnBtnFont()
{
CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd();
#ifndef _WIN32_WCE
LOGFONT lf;
pMainFrame->SelectGrid();
m_pGrid->GetFont()->GetLogFont(&lf);
CFontDialog dlg(&lf);
if (dlg.DoModal() == IDOK)
{
dlg.GetCurrentFont(&lf);
CFont Font;
Font.CreateFontIndirect(&lf);
m_pGrid->SetFont(&Font);
m_pGrid->AutoSize();
Font.DeleteObject();
}
#endif
}
示例14: PrintTitlePage
void CvMainView::PrintTitlePage(CDC* pDC, CPrintInfo* pInfo)
{
// Prepare a font size for displaying the file name
LOGFONT logFont;
memset(&logFont, 0, sizeof(LOGFONT));
// logFont.lfHeight = 75; // 3/4th inch high in MM_LOENGLISH
// (1/100th inch)
logFont.lfHeight = 200; // 2cm
CFont font;
CFont* pOldFont = NULL;
if (font.CreateFontIndirect(&logFont))
pOldFont = pDC->SelectObject(&font);
// Get the file name, to be displayed on title page
// CString strPageTitle = GetDocument()->GetTitle();
CString strPageTitle = _T("Ingres Visual Manager");
// Display the file name 1 inch below top of the page,
// centered horizontally
pDC->SetTextAlign(TA_CENTER);
pDC->TextOut(pInfo->m_rectDraw.right/2, -100, strPageTitle);
if (pOldFont != NULL)
pDC->SelectObject(pOldFont);
}
示例15: OnPaint
void CPageBase::OnPaint()
{
CPaintDC dc(this);
//填充标题栏背景
CRect rcWnd;
GetClientRect(&rcWnd);
CRect rcTitle(1,1,rcWnd.right-1,rcWnd.top+25);
dc.FillSolidRect(&rcTitle,RGB(46,64,94));
//绘制标题
if(m_pszTitle!=NULL)
{
CFont font;
font.CreateFontIndirect(&m_lfBaseFont);
CFont * pOldFont=dc.SelectObject(&font);
int nOldBkMod=dc.SetBkMode(TRANSPARENT);
DWORD dwOldTxtColor=dc.SetTextColor(RGB(255,255,255));
CSize cz=dc.GetTextExtent(m_pszTitle);
int nTitleL=4;
int nTitleT=(24-cz.cy)/2+1;
dc.TextOut(nTitleL,nTitleT,m_pszTitle,_tcslen(m_pszTitle));
dc.SetTextColor(dwOldTxtColor);
dc.SetBkMode(nOldBkMod);
dc.SelectObject(pOldFont);
}
}