Win32 API按钮看起来很新,但使用了旧字体

Win32 API button is looking new but it uses old fonts

本文关键字:字体 按钮 API 看起来 Win32      更新时间:2023-10-16

我使用Windows 7和Visual Studio 2013学习版,我是WinAPI的初学者。刚刚创建了一些按钮,代码如下:

HWND g_hPrzycisk;
g_hPrzycisk = CreateWindowEx(0, "BUTTON", "Button Here",
WS_CHILD | WS_VISIBLE | BS_CENTER, 100, 100, 150, 30, hwnd, NULL, hInstance, NULL);

按钮生成如下:https://i.stack.imgur.com/XHOkF.jpg

那么,问题出在哪里呢?我希望按钮看起来更像Windows7(使用Segoe UI字体或任何默认字体)。我一开始使用了#prgma指令,并在网上搜索了一些帮助。一无所获。如果有帮助,这里是我的#prgma

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

如果有人能帮忙,我会非常感激的。如果问题重复-对不起。

要使用通用控件v6,还需要调用InitCommonControlsEx

您可以使用WM_SETFONT为按钮指定所需的字体。