VC:CFontDialog(CClientDC 、GetDeviceCaps()、memset、LOGFONT、memcpy、CFont、SelectObject() 、IsStrikeOut())
2012-10-24 20:37
411 查看
//CFontDialog( LPLOGFONT lplfInitial = NULL, DWORD dwFlags = CF_EFFECTS | CF_SCREENFONTS, CDC* pdcPrinter = NULL, CWnd* pParentWnd = NULL );
// Show the font dialog with 12 point "Times New Roman" as the
// selected font.
/* LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
CClientDC dc(this);
lf.lfHeight = -MulDiv(12, dc.GetDeviceCaps(LOGPIXELSY), 72);
strcpy(lf.lfFaceName, "Times New Roman");
CFontDialog dlg(&lf);
dlg.DoModal();*/
/*
CFontDialog dlg;
if (dlg.DoModal() == IDOK)
{
// Create the font using the selected font from CFontDialog.
LOGFONT lf;
memcpy(&lf, dlg.m_cf.lpLogFont, sizeof(LOGFONT));
CFont font;
VERIFY(font.CreateFontIndirect(&lf));
// Do something with the font just created...
CClientDC dc(this);
CFont* def_font = dc.SelectObject(&font);
dc.TextOut(5, 5, "Hello", 5);
dc.SelectObject(def_font);
// Done with the font. Delete the font object.
font.DeleteObject();
}*/
CString fontmessage="";
CFontDialog dlg;
if( IDOK==dlg.DoModal())
{
fontmessage="字体名称:";
fontmessage+=dlg.GetFaceName();
if(1==dlg.IsStrikeOut())
fontmessage+="字体有删除线";
else
fontmessage+="字体没有删除线";
if(1==dlg.IsUnderline())
fontmessage+="字体有下划线";
else
fontmessage+="字体没有下划线";
if(1==dlg.IsBold())
fontmessage+="字体被加粗";
else
fontmessage+="字体没有被加粗";
if(1==dlg.IsItalic())
fontmessage+="字体是斜体";
else
fontmessage+="字体不是斜体";
AfxMessageBox(fontmessage);
}
// Show the font dialog with 12 point "Times New Roman" as the
// selected font.
/* LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
CClientDC dc(this);
lf.lfHeight = -MulDiv(12, dc.GetDeviceCaps(LOGPIXELSY), 72);
strcpy(lf.lfFaceName, "Times New Roman");
CFontDialog dlg(&lf);
dlg.DoModal();*/
/*
CFontDialog dlg;
if (dlg.DoModal() == IDOK)
{
// Create the font using the selected font from CFontDialog.
LOGFONT lf;
memcpy(&lf, dlg.m_cf.lpLogFont, sizeof(LOGFONT));
CFont font;
VERIFY(font.CreateFontIndirect(&lf));
// Do something with the font just created...
CClientDC dc(this);
CFont* def_font = dc.SelectObject(&font);
dc.TextOut(5, 5, "Hello", 5);
dc.SelectObject(def_font);
// Done with the font. Delete the font object.
font.DeleteObject();
}*/
CString fontmessage="";
CFontDialog dlg;
if( IDOK==dlg.DoModal())
{
fontmessage="字体名称:";
fontmessage+=dlg.GetFaceName();
if(1==dlg.IsStrikeOut())
fontmessage+="字体有删除线";
else
fontmessage+="字体没有删除线";
if(1==dlg.IsUnderline())
fontmessage+="字体有下划线";
else
fontmessage+="字体没有下划线";
if(1==dlg.IsBold())
fontmessage+="字体被加粗";
else
fontmessage+="字体没有被加粗";
if(1==dlg.IsItalic())
fontmessage+="字体是斜体";
else
fontmessage+="字体不是斜体";
AfxMessageBox(fontmessage);
}
相关文章推荐
- VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上
- VC++获取屏幕大小第三篇 物理大小GetDeviceCaps 下
- VC++获取屏幕大小第三篇 物理大小GetDeviceCaps 下
- VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上
- VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上
- VC++获取屏幕大小第三篇 物理大小GetDeviceCaps 下
- 获取屏幕信息GetDeviceCaps
- 获取屏幕大小第三篇 物理大小GetDeviceCaps 下
- 【转载】GetDeviceCaps()函数相关说明
- 获取屏幕大小第二篇 物理大小GetDeviceCaps 上
- GetDeviceCaps
- GetSystemMetrics与GetDeviceCaps
- GetDeviceCaps()函数相关说明
- GetDeviceCaps获取与修改显示器属性
- CDC::GetDeviceCaps()
- CDC::GetDeviceCaps()物理长度与屏幕像素间的转换
- MFC Windows 程序设计->GetDeviceCaps
- GetDeviceCaps WinAPI
- GetDeviceCaps
- GetDeviceCaps() 参数