All I need to do is add an icon to my program's about box.
Something like this:
So I create a dialog box using Visual Studio's editor, and add a 'picture' control. In the control's properties I change the type to 'icon' and the image field to IDI_FOHN (the id of the icon resource. Note that this same icon is also used for the my app's window and exe and works fine).
In the editor, it displays correctly (I print-screened the above image from the editor). But at run-time the dialog always displays an exclamation icon instead.
More weird is that if I add another icon to my resource script, and try to use that instead, this new icon won't display at all...?
It must be something stupid I'm doing, but I've run out of ideas. Any wild guesses welcome :)
Extract from resource.h:
#define IDC_STATICX 1056
#define IDI_FOHN 101
Extract from <program name>.rc (the about box's def)
IDD_ABOUT DIALOGEX 0, 0, 199, 151
style DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "."
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,129,121,54,14,BS_CENTER | BS_VCENTER
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,49,61,137,1
LTEXT ".",IDC_STATIC,49,67,136,43
ICON IDI_FOHN,IDC_STATICX,14,18,21,20,SS_RIGHTJUST
LTEXT ".",IDC_STATIC,48,18,133,37
END
About box's calling code and proc:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutDlgProc);
...
BOOL CALLBACK AboutDlgProc(HWND hDlg, UINT message, WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
// This code doesn't make any difference
/*HICON hIcon;
HWND child;
hIcon = LoadIcon(m_instance, MAKEINTRESOURCE(IDI_FOHN));
child = GetDlgItem(hDlg, IDC_STATICX);
SendMessage(child, BM_SETIMAGE, (WPARAM) IMAGE_ICON,
(LPARAM) hIcon);*/
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDCANCEL:
case IDOK:
EndDialog(hDlg, 0);
return TRUE;
}
break;
}
return FALSE;
}