windows - 如何确定对话框窗口中使用的字体

标签 windows fonts dialog window analysis

如何确定 Windows 上运行过程中某些对话框窗口中某些控件所使用的字体?像 Microsoft Spy++ 那样的东西。

最佳答案

我在 Spy++ 中没有找到此功能,但这是我刚刚为此任务编写的一个小程序:

#include <windows.h>
#include <stdio.h>

int main(int argc, char **argv)
{
    if (argc != 2) {
        fprintf(stderr, "Usage: findfont WINDOWTITLE\n");
        return 1;
    }
    LPCSTR title = argv[1];
    HWND hWnd = FindWindow(NULL, title);
    if (hWnd == NULL) {
        fprintf(stderr, "Window titled \"%s\" not found\n", title);
        return 1;
    }
    HFONT hFont = (HFONT) SendMessage(hWnd, WM_GETFONT, 0, 0);
    if (hFont == NULL) {
        fprintf(stderr, "WM_GETFONT failed\n");
        return 1;
    }
    LOGFONT lf = { 0 };
    if (!GetObject(hFont, sizeof(LOGFONT), &lf)) {
        fprintf(stderr, "GetObject failed\n");
        return 1;
    }
    printf("Face name: %s Height: %ld\n", lf.lfFaceName, lf.lfHeight);
    return 0;
}

关于windows - 如何确定对话框窗口中使用的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51783776/

相关文章:

c++ - 从未调用过 WSASend 完成例程

Javascript Prompt() 在 Android 浏览器中出现暗淡(微弱)的提示消息

android - 使用 keytool 以非交互方式生成 key

css - 设置 SVG 的后备字体

fonts - 如何避免 Google Web-Fonts 的不确定性

c++ - Qt:用于换行文本的 heightForWidth

android - 自定义对话框或对话框主题 Activity

javascript - 未定义错误的警报触发

php - 在 Windows 上使用 XAMPP 安装 PHP YAML 扩展

用于安装多个 perl 模块的 Windows 批处理文件 - 仅运行第一行