[RESOLVED] Displaying an icon in a simple dialog with winapi
I made a dialog to have a customizable msgbox. (custom icon, custom caption on buttons).
This is how I try to display an icon on the dialog but it is not working. Can anyone help?
HICON hIcon = LoadIcon(NULL, IDI_QUESTION);
HWND hImageCtl = GetDlgItem(hDlg, IDC_STATIC);
::SendMessage(hImageCtl, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
//SendDlgItemMessage(hDlg, IDC_STATIC, STM_SETICON, (WPARAM) hIcon, 0);
Re: Displaying an icon in a simple dialog with winapi
- Change the static control ID from IDC_STATIC to something else, for example IDC_STATIC_ICON
- If it still won't display - debug your code to see the return values of all the functions you call.
Re: Displaying an icon in a simple dialog with winapi
The name was not ok. Ty for your help. (I had a static text box with IDC_STATIC, I deleted it and thought I could reuse the ID, something went wrong there).
Re: Displaying an icon in a simple dialog with winapi
Sorry. What did you mean by "name"?
BTW, did you change the picture control ID from IDC_STATIC to something else? Does it work now?
Re: Displaying an icon in a simple dialog with winapi
Yes the IDC_STATIC was not ok. (probably because it was before reused by a static text control that I've deleted meantime). I've changed the control's ID as you suggested to ID_STATIC_ICON and it worked.
Re: Displaying an icon in a simple dialog with winapi
Glad to know it! :)
Now you might want to mark this thread as RESOLVED (see http://forums.codeguru.com/faq.php?f..._item_resolved )