-
February 27th, 2013, 09:44 AM
#1
[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);
-
February 27th, 2013, 11:26 AM
#2
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.
Victor Nijegorodov
-
February 28th, 2013, 03:04 AM
#3
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).
-
February 28th, 2013, 03:44 AM
#4
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?
Victor Nijegorodov
-
February 28th, 2013, 04:48 AM
#5
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.
-
February 28th, 2013, 04:54 AM
#6
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 )
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|