CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Posts
    15

    [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);

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: Displaying an icon in a simple dialog with winapi

    1. Change the static control ID from IDC_STATIC to something else, for example IDC_STATIC_ICON
    2. If it still won't display - debug your code to see the return values of all the functions you call.
    Victor Nijegorodov

  3. #3
    Join Date
    Oct 2012
    Posts
    15

    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).

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    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

  5. #5
    Join Date
    Oct 2012
    Posts
    15

    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.

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    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
  •  





Click Here to Expand Forum to Full Width

Featured