win32-在按钮中使用默认按钮字体 [英] win32 - Using the default button font in a button

查看:63
本文介绍了win32-在按钮中使用默认按钮字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用C ++创建一个小的WinAPI应用程序.我正在尝试使用以下代码在表单上创建一个按钮:

I'm creating a small WinAPI application in C++. I am trying to create a button on my form by using the code:

HWND hwndButton = CreateWindow(
    TEXT("BUTTON"),   
    TEXT("Click Here"),       
    WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,  // Styles 
    10,         
    10,         
    100,        
    30,        
    hwnd,     
    NULL,       
    (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE),
    NULL);     

此代码基于MSDN示例.我的问题是,它在按钮上使用了粗体,如下所示:

This code is based off of an MSDN sample. My issue is that it uses a bold font on the button like this:

当我想使用这样的标准字体时:

When I want to use the standard font like this:

我已经在文件顶部添加了预处理指令,以启用视觉样式.

I already have the preprocessor directive at the top of my file to enable visual styles.

#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

使用标准系统范围的字体应该采取什么步骤?

What steps should I take to use the standard system wide font?

谢谢

推荐答案

没有诸如控件的默认系统范围字体之类的东西,最初您会获得一个使用"System"字体创建的控件,这就是您在第一张图片上看到的内容.当将按钮创建为对话框的一部分时,它使用对话框模板中的字体,因此在按钮上使用具有适当大小+ WM_SETFONT的"MS Shell Dlg"之类的东西应该会得到与图片2相同的结果.请注意,没有系统上的物理MS Shell Dlg字体,它已根据注册表设置映射为特定字体.

There's no such thing as default system wide font for controls, initially you get a control created with "System" font, that's what you see on first picture. When button is created as part of a dialog, it uses a font from dialog template, so using something like "MS Shell Dlg" with appropriate size + WM_SETFONT on a button should give you the same result as on picture 2. Note that there's no physical MS Shell Dlg font on a system, it's mapped to particular font according to registry settings.

公用控件清单与此无关,而行为与comctl32版本6相同.

Common control manifest has nothing to do with this, behavior has not changed with comctl32 version 6.

这篇关于win32-在按钮中使用默认按钮字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆