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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Changing the Icon

Changing the Icon

Scheduled Pinned Locked Moved C#
c++csharpquestion
6 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.
  • D Offline
    D Offline
    ddspliting
    wrote on last edited by
    #1

    In Visual C++ programing, we can change the icon of the EXE file.Is it possible to change the icon of a window form program's EXE in C#? if it is then i will be grateful if anyone tell me about it... waiting....

    P L E 3 Replies Last reply
    0
    • D ddspliting

      In Visual C++ programing, we can change the icon of the EXE file.Is it possible to change the icon of a window form program's EXE in C#? if it is then i will be grateful if anyone tell me about it... waiting....

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      Try googling around :)

      "I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon

      1 Reply Last reply
      0
      • D ddspliting

        In Visual C++ programing, we can change the icon of the EXE file.Is it possible to change the icon of a window form program's EXE in C#? if it is then i will be grateful if anyone tell me about it... waiting....

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Some comments on applications and icons: 1. An application typically has two different icons: - the application itself has an icon at the file level; it gets used by Windows Explorer; you set it as a project property. - any form can have an icon; it is a Form property, that you can set through Visual Designer. It also shows up in the task bar's button (if the Form shows in task bar). 2. an icon file can hold multiple icons (icons at different sizes), and Windows will pick one depending on circumstances, so if they do not all look alike, you may get very confused. 3. I tend to create icons programmatically; the following code converts a (best small, square) image into a simple icon:

        string filename=popupNode.getLongName();
        try {
        Bitmap bm=(Bitmap)Image.FromFile(filename);
        if(bm.Width!=32 || bm.Height!=32) {
        bm=new Bitmap(bm, 32, 32);
        }
        Icon icon=Icon.FromHandle(bm.GetHicon());
        bm.Dispose();
        string filename2=Path.ChangeExtension(filename, ".ico");
        Stream stream=new FileStream(filename2, FileMode.Create);
        icon.Save(stream);
        env.output("Created icon "+filename2);
        } catch(Exception exc) {
        env.output("Failed to create icon from "+filename);
        env.log(exc);
        }

        Hope this helps.

        Luc Pattyn [Forum Guidelines] [My Articles]


        Happy 2008!


        D 1 Reply Last reply
        0
        • L Luc Pattyn

          Some comments on applications and icons: 1. An application typically has two different icons: - the application itself has an icon at the file level; it gets used by Windows Explorer; you set it as a project property. - any form can have an icon; it is a Form property, that you can set through Visual Designer. It also shows up in the task bar's button (if the Form shows in task bar). 2. an icon file can hold multiple icons (icons at different sizes), and Windows will pick one depending on circumstances, so if they do not all look alike, you may get very confused. 3. I tend to create icons programmatically; the following code converts a (best small, square) image into a simple icon:

          string filename=popupNode.getLongName();
          try {
          Bitmap bm=(Bitmap)Image.FromFile(filename);
          if(bm.Width!=32 || bm.Height!=32) {
          bm=new Bitmap(bm, 32, 32);
          }
          Icon icon=Icon.FromHandle(bm.GetHicon());
          bm.Dispose();
          string filename2=Path.ChangeExtension(filename, ".ico");
          Stream stream=new FileStream(filename2, FileMode.Create);
          icon.Save(stream);
          env.output("Created icon "+filename2);
          } catch(Exception exc) {
          env.output("Failed to create icon from "+filename);
          env.log(exc);
          }

          Hope this helps.

          Luc Pattyn [Forum Guidelines] [My Articles]


          Happy 2008!


          D Offline
          D Offline
          ddspliting
          wrote on last edited by
          #4

          Thnxx for sharing this precious info! But the fact is i ve changed the form icon as u mentioned i guess.Now i want to change that exe file icon. say in the debug there is a exe file named "dark.exe".This file has its typical exe icon.you know which is common for windows! tht window like. Now as in visual C++ we can change exe file icon to any icon file we want or can convert a bitmap to icon file like you ve posted the code for it.There is already option for tht in the IDE. If there is an option present in C# IDE(i m using Visual Studio 2005 by the way) then i ll be glad if you tell me if u know already! or other method ....

          L 1 Reply Last reply
          0
          • D ddspliting

            Thnxx for sharing this precious info! But the fact is i ve changed the form icon as u mentioned i guess.Now i want to change that exe file icon. say in the debug there is a exe file named "dark.exe".This file has its typical exe icon.you know which is common for windows! tht window like. Now as in visual C++ we can change exe file icon to any icon file we want or can convert a bitmap to icon file like you ve posted the code for it.There is already option for tht in the IDE. If there is an option present in C# IDE(i m using Visual Studio 2005 by the way) then i ll be glad if you tell me if u know already! or other method ....

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            Hi, the app's exe icon is a project property, hence right click the project in the solution pane, choose application tab, and specify the icon file/resource there. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            Happy 2008!


            1 Reply Last reply
            0
            • D ddspliting

              In Visual C++ programing, we can change the icon of the EXE file.Is it possible to change the icon of a window form program's EXE in C#? if it is then i will be grateful if anyone tell me about it... waiting....

              E Offline
              E Offline
              Ed Poore
              wrote on last edited by
              #6

              Just look in the properties pages for the project. If you want to embed multiple icons into the executable which are viewable by Windows then might I suggest taking a look at my article[^]. Shameless self-publicising but hey...


              My Blog[^]

              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