[求助]对话框设置图标(左上角那个小图标)问题
我在读<<windows核心编程》22章DIPS程序时遇到的问题:作者为设置对话框图标定义了一函数:
// Sets the dialog box icons
inline void chSETDLGICONS(HWND hwnd, int idi) {
SendMessage(hwnd, WM_SETICON, TRUE, (LPARAM)
LoadIcon((HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),MAKEINTRESOURCE(idi)));
SendMessage(hwnd, WM_SETICON, FALSE, (LPARAM)
LoadIcon((HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),MAKEINTRESOURCE(idi)));
}
问题一:为何用两次SendMessage(...)
========================================================================
又作者设置图标的代码:
BOOL Dlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) {
chSETDLGICONS(hwnd, IDI_DIPS);
return(TRUE);
}
void Dlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) {
switch (id) {
case IDC_SAVE:
case IDC_RESTORE:
case IDCANCEL:
EndDialog(hwnd, id);
break;
}
}
BOOL WINAPI Dlg_Proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
chHANDLE_DLGMSG(hwnd, WM_INITDIALOG, Dlg_OnInitDialog);
chHANDLE_DLGMSG(hwnd, WM_COMMAND, Dlg_OnCommand);
}
return(FALSE);
}
问题二:在Dlg_Proc中并未处理WM_SETICON消息,难道对话框自己处理了?
======================================================================================
问题三:我试图如下设置icon: SetClassLong(hwnd,GCL_HICON,IDI_DIPS);
可是failed!窗口不是依据窗口类而来吗?设置窗口类的icon不是设置窗口属性吗?