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. How to update a exe icon from within

How to update a exe icon from within

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionannouncement
5 Posts 2 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
    The Lady of Shallots
    wrote on last edited by
    #1

    Hello everyone, I want to update the icon of my app at runtime after checking to see if a certain condition is true. The new icon to use is defined in my resources. I have looked through past posts on this subject and found some information (mostly using UpdateResource), however I have not been able to get it to work. Here is the code I've got so far: if( bcondition == TRUE){ HANDLE hIcon = LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); UpdateResource (hIcon, RT_ICON, MAKEINTRESOURCE(IDI_NEWICON), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL,0); } I'm probably totally off here (sorry, still a newbie :)), also where should I put this? Does it need to be at a certain point during the creation of the app? Thanks so much!

    L 1 Reply Last reply
    0
    • T The Lady of Shallots

      Hello everyone, I want to update the icon of my app at runtime after checking to see if a certain condition is true. The new icon to use is defined in my resources. I have looked through past posts on this subject and found some information (mostly using UpdateResource), however I have not been able to get it to work. Here is the code I've got so far: if( bcondition == TRUE){ HANDLE hIcon = LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); UpdateResource (hIcon, RT_ICON, MAKEINTRESOURCE(IDI_NEWICON), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL,0); } I'm probably totally off here (sorry, still a newbie :)), also where should I put this? Does it need to be at a certain point during the creation of the app? Thanks so much!

      L Offline
      L Offline
      LiquidKnight
      wrote on last edited by
      #2

      Im not exactly sure on what you mean by "update" your icon. I am assuming you mean to change the icon on the window of the application itself and not the EXE's icon completely. If this is wrong say so. But anyways to update an icon on the window itself you could do it a varity of ways. If your using MFC you could simply use SetIcon after loading it from the resource using the LoadIcon function. If your talking about doing this in a Win32 application you may have to do it a bit differnt. If you mean your trying to update the icon for the EXE completely so that even the icon of the .exe file in your folder changes it would be a bit more hard. For more info feel free to contact me im not sure exactly what your question is my AIM is LiquidIceKnight or vethax0r my MSN is spartacushaxor@hotmail.com (dont email me here) if you only have yahoo my yahoo name is killereaglesoftware, and if you really don't have any of those and must reply to me only by means of email when it would be so much easier to explain through means of chatting feel free to email me. killereaglesoftware@yahoo.com - LiquidKnight

      T 1 Reply Last reply
      0
      • L LiquidKnight

        Im not exactly sure on what you mean by "update" your icon. I am assuming you mean to change the icon on the window of the application itself and not the EXE's icon completely. If this is wrong say so. But anyways to update an icon on the window itself you could do it a varity of ways. If your using MFC you could simply use SetIcon after loading it from the resource using the LoadIcon function. If your talking about doing this in a Win32 application you may have to do it a bit differnt. If you mean your trying to update the icon for the EXE completely so that even the icon of the .exe file in your folder changes it would be a bit more hard. For more info feel free to contact me im not sure exactly what your question is my AIM is LiquidIceKnight or vethax0r my MSN is spartacushaxor@hotmail.com (dont email me here) if you only have yahoo my yahoo name is killereaglesoftware, and if you really don't have any of those and must reply to me only by means of email when it would be so much easier to explain through means of chatting feel free to email me. killereaglesoftware@yahoo.com - LiquidKnight

        T Offline
        T Offline
        The Lady of Shallots
        wrote on last edited by
        #3

        Yup, you are right in saying I'm trying to update my icon. I don't want to change it completely in the exe, just update it so the user see something different at runtime. I am using MFC, I will give it a shot with the SetIcon and let you know what happens. Thanks so much for your help!

        L 1 Reply Last reply
        0
        • T The Lady of Shallots

          Yup, you are right in saying I'm trying to update my icon. I don't want to change it completely in the exe, just update it so the user see something different at runtime. I am using MFC, I will give it a shot with the SetIcon and let you know what happens. Thanks so much for your help!

          L Offline
          L Offline
          LiquidKnight
          wrote on last edited by
          #4

          feel free to message if u have any other questions i know alot :/ lol - LiquidKnight

          T 1 Reply Last reply
          0
          • L LiquidKnight

            feel free to message if u have any other questions i know alot :/ lol - LiquidKnight

            T Offline
            T Offline
            The Lady of Shallots
            wrote on last edited by
            #5

            Got it to work with SetIcon! Thanks so much! :)

            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