Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. "wrong" application icon in dialog based application

"wrong" application icon in dialog based application

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestionannouncementlearning
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    T T H
    wrote on last edited by
    #1

    Hi everyone When I use Visual C++ 6 to build a Doc/View application the final application will have an icon it its title bar. This icon is 16 x 16 pixel and looks exactly as the corresponding 16 x 16 pixel version of the icon I can edit in the resource editor. On the other side when I build a dialog based application it will have an icon in its title bar, too, it is 16 x 16 pixel in size, too, but it does not look the same as the icon I can edit in the resource editor. I guess it is "shrunken" from the 32 x 32 pixel version of the icon in the resource editor, nevertheless it is not what I want because this "shrunken" icon looks distorted. A screenshot demonstrating this behaviour: http://www.teeteehaa.de/pictures/applicationicon.gif Can anbody explain me the reason for this and how to prevent it? Thanks, Matthias "T.T.H." Grobe

    L D PJ ArendsP 3 Replies Last reply
    0
    • T T T H

      Hi everyone When I use Visual C++ 6 to build a Doc/View application the final application will have an icon it its title bar. This icon is 16 x 16 pixel and looks exactly as the corresponding 16 x 16 pixel version of the icon I can edit in the resource editor. On the other side when I build a dialog based application it will have an icon in its title bar, too, it is 16 x 16 pixel in size, too, but it does not look the same as the icon I can edit in the resource editor. I guess it is "shrunken" from the 32 x 32 pixel version of the icon in the resource editor, nevertheless it is not what I want because this "shrunken" icon looks distorted. A screenshot demonstrating this behaviour: http://www.teeteehaa.de/pictures/applicationicon.gif Can anbody explain me the reason for this and how to prevent it? Thanks, Matthias "T.T.H." Grobe

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I'm guessing here, but its probably a subtle change microsoft made to distinguish MFC dialogs from MFC apps. You could just use the dialog editor to copy the icon you want and paste it into the dialog project? Hope this helps.

      1 Reply Last reply
      0
      • T T T H

        Hi everyone When I use Visual C++ 6 to build a Doc/View application the final application will have an icon it its title bar. This icon is 16 x 16 pixel and looks exactly as the corresponding 16 x 16 pixel version of the icon I can edit in the resource editor. On the other side when I build a dialog based application it will have an icon in its title bar, too, it is 16 x 16 pixel in size, too, but it does not look the same as the icon I can edit in the resource editor. I guess it is "shrunken" from the 32 x 32 pixel version of the icon in the resource editor, nevertheless it is not what I want because this "shrunken" icon looks distorted. A screenshot demonstrating this behaviour: http://www.teeteehaa.de/pictures/applicationicon.gif Can anbody explain me the reason for this and how to prevent it? Thanks, Matthias "T.T.H." Grobe

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        It may be the 16x16 vs. 32x32 thing that's ailing you.

        1 Reply Last reply
        0
        • T T T H

          Hi everyone When I use Visual C++ 6 to build a Doc/View application the final application will have an icon it its title bar. This icon is 16 x 16 pixel and looks exactly as the corresponding 16 x 16 pixel version of the icon I can edit in the resource editor. On the other side when I build a dialog based application it will have an icon in its title bar, too, it is 16 x 16 pixel in size, too, but it does not look the same as the icon I can edit in the resource editor. I guess it is "shrunken" from the 32 x 32 pixel version of the icon in the resource editor, nevertheless it is not what I want because this "shrunken" icon looks distorted. A screenshot demonstrating this behaviour: http://www.teeteehaa.de/pictures/applicationicon.gif Can anbody explain me the reason for this and how to prevent it? Thanks, Matthias "T.T.H." Grobe

          PJ ArendsP Offline
          PJ ArendsP Offline
          PJ Arends
          wrote on last edited by
          #4

          This is because CWinApp::LoadIcon will only load the large 32 x 32 pixel icon, and when you call CWnd::SetIcon(m_hIcon, FALSE), the SetIcon() function will shrink the 32 x 32 icon to 16 x 16. The fix is to add another icon member to your dialog class to hold the small icon, use LoadImage() to load it, and set that as your small icon

          class CMyDialog : public CDialog
          {
          protected:
          HICON m_hIcon;
          HICON m_hSmallIcon;
          ...
          };

          CMyDialog::CMyDialog(...
          {
          m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
          m_hSmallIcon = (HICON)LoadImage(AfxGetInstanceHandle(),
          MAKEINTRESOURCE(IDR_MAINFRAME),
          IMAGE_ICON,
          16, 16,
          LR_DEFAULTCOLOR);
          ...
          }

          BOOL CMyDialog::OnInitDialog()
          {
          ...
          SetIcon(m_hIcon, TRUE); // Set big icon
          SetIcon(m_hSmallIcon, FALSE); // Set small icon
          ...
          }


          [

          ](http://www.canucks.com)Sonork 100.11743 Chicken Little "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 Within you lies the power for good - Use it!

          Within you lies the power for good; Use it!

          T 1 Reply Last reply
          0
          • PJ ArendsP PJ Arends

            This is because CWinApp::LoadIcon will only load the large 32 x 32 pixel icon, and when you call CWnd::SetIcon(m_hIcon, FALSE), the SetIcon() function will shrink the 32 x 32 icon to 16 x 16. The fix is to add another icon member to your dialog class to hold the small icon, use LoadImage() to load it, and set that as your small icon

            class CMyDialog : public CDialog
            {
            protected:
            HICON m_hIcon;
            HICON m_hSmallIcon;
            ...
            };

            CMyDialog::CMyDialog(...
            {
            m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
            m_hSmallIcon = (HICON)LoadImage(AfxGetInstanceHandle(),
            MAKEINTRESOURCE(IDR_MAINFRAME),
            IMAGE_ICON,
            16, 16,
            LR_DEFAULTCOLOR);
            ...
            }

            BOOL CMyDialog::OnInitDialog()
            {
            ...
            SetIcon(m_hIcon, TRUE); // Set big icon
            SetIcon(m_hSmallIcon, FALSE); // Set small icon
            ...
            }


            [

            ](http://www.canucks.com)Sonork 100.11743 Chicken Little "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 Within you lies the power for good - Use it!

            T Offline
            T Offline
            T T H
            wrote on last edited by
            #5

            Thank you very much for the precise answer, this exactly solved my problem! T.T.H. - *happy* :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups