设计界面时需要有 edit 类的控件(我不使用MFC,但使用 VC++ 6.0)。因我还不知道如何让预定义的 edit 类窗口按我要求的 LOFFONT 去显示,而自己重新设计 edit 的窗口函数很花功夫。从 MSDN 中看到 WM_SETFONT 消息,就先试着截获 WM_SETFONT 或 WM_GETFONT 消息,象如下: if(msg==WM_SETFONT)
{
LOGFONT logfont;
memset(&logfont,0,sizeof(logfont));
logfont.lfHeight=14;
......
wParam=(WPARAM)CreateFontIndirect(&logfont);
}
return CallWindowProc(OldEWndProc,hwnd, msg, wParam, lParam);但是没有任何效果。究竟如何处理?
{
LOGFONT logfont;
memset(&logfont,0,sizeof(logfont));
logfont.lfHeight=14;
......
wParam=(WPARAM)CreateFontIndirect(&logfont);
}
return CallWindowProc(OldEWndProc,hwnd, msg, wParam, lParam);但是没有任何效果。究竟如何处理?
"应该是主动向EDIT控件以送WM_SETFONT消息来设置显示的字体. 参数参考MSDN对WM_SETFONT消息的说明"
说得对,就算是在MFC中有很多控件重会也可使用类似方法,很方便
SendMessage(hEdit, WM_SETFONT, (WPARAM)hFont, (LPARAM)TRUE);