是否有任何文档由 DefWindowProc 处理哪些消息,以及如何处理?
我最近偶然发现 WM_SETFONT/WM_GETFONT 没有被处理,我不确定我的代码是否有错误,或者这是预期的行为,所以我尝试了以下 WinMain:
WNDCLASSEX wcx =
{
sizeof(WNDCLASSEX),
CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS,
DefWindowProc,
0, 0, // class/wnd extra bytes
hInstance,
0,
LoadCursor(0, IDC_ARROW),
0,
0,
_T("some class"),
0
};
ATOM a = RegisterClassEx(&wcx);
_ASSERTE(a != 0);
HWND wnd = CreateWindowEx(0, wcx.lpszClassName, NULL,
WS_POPUP, 0,0,0,0, GetDesktopWindow(), 0, hInstance, 0);
_ASSERTE(wnd != 0);
HFONT font = (HFONT) GetStockObject(ANSI_VAR_FONT);
_ASSERTE(font != 0);
SendMessage(wnd, WM_SETFONT, (WPARAM) font, 0);
HFONT font2 = (HFONT) SendMessage(wnd, WM_GETFONT, 0, 0);
_ASSERTE(font2 == font); // **FAILS**, font2 is 0