VC怎么能获取系统字体
3个回答
展开全部
通过GetStockObject函数可以取得系统字体。
The GetStockObject function retrieves a handle to one of the stock pens, brushes, fonts, or palettes.
HGDIOBJ GetStockObject(
int fnObject // stock object type
);
其中fnObject可以是以下字体:
ANSI_FIXED_FONT Windows fixed-pitch (monospace) system font.
ANSI_VAR_FONT Windows variable-pitch (proportional space) system font.
DEVICE_DEFAULT_FONT Windows NT/2000/XP: Device-dependent font.
DEFAULT_GUI_FONT Default font for user interface objects such as menus and dialog boxes. This is MS Sans Serif. Compare this with SYSTEM_FONT.
OEM_FIXED_FONT Original equipment manufacturer (OEM) dependent fixed-pitch (monospace) font.
SYSTEM_FONT System font. By default, the system uses the system font to draw menus, dialog box controls, and text.
Windows 95/98 and Windows NT: The system font is MS Sans Serif.
Windows 2000/XP: The system font is Tahoma
SYSTEM_FIXED_FONT Fixed-pitch (monospace) system font. This stock object is provided only for compatibility with 16-bit Windows versions earlier than 3.0.
The GetStockObject function retrieves a handle to one of the stock pens, brushes, fonts, or palettes.
HGDIOBJ GetStockObject(
int fnObject // stock object type
);
其中fnObject可以是以下字体:
ANSI_FIXED_FONT Windows fixed-pitch (monospace) system font.
ANSI_VAR_FONT Windows variable-pitch (proportional space) system font.
DEVICE_DEFAULT_FONT Windows NT/2000/XP: Device-dependent font.
DEFAULT_GUI_FONT Default font for user interface objects such as menus and dialog boxes. This is MS Sans Serif. Compare this with SYSTEM_FONT.
OEM_FIXED_FONT Original equipment manufacturer (OEM) dependent fixed-pitch (monospace) font.
SYSTEM_FONT System font. By default, the system uses the system font to draw menus, dialog box controls, and text.
Windows 95/98 and Windows NT: The system font is MS Sans Serif.
Windows 2000/XP: The system font is Tahoma
SYSTEM_FIXED_FONT Fixed-pitch (monospace) system font. This stock object is provided only for compatibility with 16-bit Windows versions earlier than 3.0.
参考资料: MSDN
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
展开全部
你说的系统字体指的是窗口视默认使用的字体的话,可以用以下方法获得:
在View类里
CFont *f= this->GetFont();
f就是当前窗口视默认使用的字体对象指针
在View类里
CFont *f= this->GetFont();
f就是当前窗口视默认使用的字体对象指针
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐于2016-07-20 · 知道合伙人互联网行家
关注
展开全部
VC 获取已系统安装的字体
BOOL CALLBACK EnumFonts(CONST LOGFONT* lplf, CONST TEXTMETRIC *lptm,DWORD dwType,LPARAM lparam)
{
CString tempFontName(lplf->lfFaceName);
CString temp=gSysFontNames;
if(tempFontName.Find("@")!=-1)
return true;
//可对tempFontName自行附加过滤条件
//{
gSysFontNames.Format("%s,%s",temp,tempFontName);
//}
return true;
}
void CDialogTest:OnButton1()
{
AfxMessageBox(GetSystemFontName((LPVOID)this);
}
CString CDialogTest::GetSysFontName(LPVOID lp)
{
gSysFontNames="";
try
{
CPaintDC dc((CWnd*)lp);
::EnumFonts(dc.m_hDC,NULL,(FONTENUMPROC)EnumFonts,0);
return gSysFontNames.Mid(1);
}
catch(...)
{
return "";
}
}
BOOL CALLBACK EnumFonts(CONST LOGFONT* lplf, CONST TEXTMETRIC *lptm,DWORD dwType,LPARAM lparam)
{
CString tempFontName(lplf->lfFaceName);
CString temp=gSysFontNames;
if(tempFontName.Find("@")!=-1)
return true;
//可对tempFontName自行附加过滤条件
//{
gSysFontNames.Format("%s,%s",temp,tempFontName);
//}
return true;
}
void CDialogTest:OnButton1()
{
AfxMessageBox(GetSystemFontName((LPVOID)this);
}
CString CDialogTest::GetSysFontName(LPVOID lp)
{
gSysFontNames="";
try
{
CPaintDC dc((CWnd*)lp);
::EnumFonts(dc.m_hDC,NULL,(FONTENUMPROC)EnumFonts,0);
return gSysFontNames.Mid(1);
}
catch(...)
{
return "";
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询