Windows 如何确定对话框窗口中使用的字体
在Windows上运行进程时,如何确定某些对话框窗口中某些控件使用的字体?类似于Microsoft Spy++的功能。我在Spy++中没有找到此功能,但这里有一个我刚刚为此任务编写的小程序:Windows 如何确定对话框窗口中使用的字体,windows,fonts,dialog,window,analysis,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 WINDO
#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;
}
#包括
#包括
int main(int argc,字符**argv)
{
如果(argc!=2){
fprintf(stderr,“用法:findfont WINDOWTITLE\n”);
返回1;
}
LPCSTR标题=argv[1];
HWND HWND=FindWindow(空,标题);
if(hWnd==NULL){
fprintf(stderr,“标题为\%s\”的窗口未找到\n”,标题);
返回1;
}
HFONT HFONT=(HFONT)SendMessage(hWnd,WM_GETFONT,0,0);
if(hFont==NULL){
fprintf(stderr,“WM_GETFONT失败\n”);
返回1;
}
LOGFONT lf={0};
if(!GetObject(hFont,sizeof(LOGFONT),&lf)){
fprintf(stderr,“GetObject失败\n”);
返回1;
}
printf(“面名称:%s高度:%ld\n”,lf.lfFaceName,lf.lfHeight);
返回0;
}