CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15
  1. #1
    Join Date
    Feb 2012
    Posts
    7

    Question How can a dialog have two different icons?

    Hi

    I am trying to make my application, which is an MFC dialog based application, have the titlebar/system menu icon different from the one showing in the taskbar.

    How can this be achieved?

    Thanks

  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: How can a dialog have two different icons?

    As far as I know there is only 1 icon. What you could do is handle the minimize/restore events yourself and change the icon when the window is minimized or restored.

    Is there any reason to change the windows default behavior ?

  3. #3
    Join Date
    Feb 2012
    Posts
    7

    Re: How can a dialog have two different icons?

    My dialog application can open different dialogs each with its unique icon.. I want all those dialogs to have different icons in their system tray yet they all share the same icon in the taskbar.

  4. #4
    Join Date
    Feb 2012
    Posts
    7

    Re: How can a dialog have two different icons?

    Quote Originally Posted by redserpent7 View Post
    My dialog application can open different dialogs each with its unique icon.. I want all those dialogs to have different icons in their system tray yet they all share the same icon in the taskbar.
    Sorry I meant system menu not *tray

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

    Re: How can a dialog have two different icons?

    Quote Originally Posted by redserpent7 View Post
    Hi

    I am trying to make my application, which is an MFC dialog based application, have the titlebar/system menu icon different from the one showing in the taskbar.

    How can this be achieved?
    Using CWnd::SetIcon
    Victor Nijegorodov

  6. #6
    Join Date
    Feb 2012
    Posts
    7

    Re: How can a dialog have two different icons?

    SetIcon will set the icon for both the title bar and the task bar icons

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

    Re: How can a dialog have two different icons?

    Quote Originally Posted by redserpent7 View Post
    SetIcon will set the icon for both the title bar and the task bar icons
    Yes, you are right!
    And sorry! I never changed the icon of the main dialog of a dialog based app, I only did it for child windows.
    Victor Nijegorodov

  8. #8
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: How can a dialog have two different icons?

    I wanted to suggest a hack, hoping that Windows uses different resolution of the same icon in the title bar and task bar.
    Sorry, no luck – on my system they both use 32x32, 32-bit.
    I guess you’d have to handle non-client painting yourself.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  9. #9
    Join Date
    Feb 2012
    Posts
    7

    Re: How can a dialog have two different icons?

    Quote Originally Posted by VladimirF View Post
    I guess you’d have to handle non-client painting yourself.
    I wont mind doing that except I'm not what the right approach is or how can I get a handle to the taskbar button

  10. #10
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: How can a dialog have two different icons?

    Quote Originally Posted by redserpent7 View Post
    I wont mind doing that except I'm not what the right approach is or how can I get a handle to the taskbar button
    I would suggest to leave the task bar alone (use SetIcon there), and handle NC_PAINT to paint different icon on the title bar of your window.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

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

    Re: How can a dialog have two different icons?

    Quote Originally Posted by VladimirF View Post
    I wanted to suggest a hack, hoping that Windows uses different resolution of the same icon in the title bar and task bar.
    Sorry, no luck
    Yeah, I did the same test after OP had coplained in the post#6! And couldn't achieve it either.
    Victor Nijegorodov

  12. #12
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: How can a dialog have two different icons?

    Handling WM_GETICON does the trick. See the sample.
    Attached Files Attached Files
    Best regards,
    Igor

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

    Re: How can a dialog have two different icons?

    Quote Originally Posted by Igor Vartanov View Post
    Handling WM_GETICON does the trick. See the sample.
    Good point, Igor!
    Victor Nijegorodov

  14. #14
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: How can a dialog have two different icons?

    Quote Originally Posted by Igor Vartanov View Post
    Handling WM_GETICON does the trick. See the sample.
    Super!
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  15. #15
    Join Date
    Feb 2012
    Posts
    7

    Re: How can a dialog have two different icons?

    Quote Originally Posted by Igor Vartanov View Post
    Handling WM_GETICON does the trick. See the sample.
    Wow man, super and excellent all I did was assign ICON_SMALL2 a diiferent icon than ICON_SMALL..

    Thanks a lot man...

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