//设置子控件字体
BOOL CALLBACK SetChildFont(HWND hwnd,LPARAM hFont)
{
SendMessage(hwnd,WM_SETFONT,(WPARAM)hFont,TRUE);
return TRUE;
}
//主窗口建立,即WM_CREATE
BOOL OnCreate(HWND hwnd,LPCREATESTRUCT lpCreateStruct)
{
//建立字体
LOGFONT LogFont;
HFONT hFont;
memset(&LogFont,0,sizeof(LOGFONT));
_tcscpy(LogFont.lfFaceName, _T("宋体"));
LogFont.lfHeight = 12;
hFont = CreateFontIndirect(&LogFont);
//建立2个文本框
edit_create_state=CreateWindow(TEXT("EDIT"),TEXT(""),WS_VISIBLE|WS_CHILD|WS_BORDER|ES_AUTOHSCROLL,
0,0,0,0,hwnd,(HMENU)BOX_CREATE,lpCreateStruct->hInstance,NULL);
edit_size_state=CreateWindowEx(WS_EX_CLIENTEDGE,TEXT("EDIT"),TEXT(""),WS_VISIBLE|WS_CHILD|WS_BORDER|ES_AUTOHSCROLL,
0,0,0,0,hwnd,(HMENU)BOX_SIZE,lpCreateStruct->hInstance,NULL);
//枚举窗口里的子控件并设置它们的字体
EnumChildWindows(hwnd,SetChildFont,(LPARAM)hFont);
return TRUE;
}