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#
  4. Getting application Icon

Getting application Icon

Scheduled Pinned Locked Moved C#
5 Posts 3 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
    Dirso
    wrote on last edited by
    #1

    Hi, I made a Form derivated class and I'd like to put some code in the Load event so when I use it, it will get the application icon (if any) and show it in the top left corner (as any windows software). I saw I few methods but they assume I know the namespace and the icon name, but as I told you the form may be used in any application, so I have to find out those informations too... Thanks, Dirso

    C H 2 Replies Last reply
    0
    • D Dirso

      Hi, I made a Form derivated class and I'd like to put some code in the Load event so when I use it, it will get the application icon (if any) and show it in the top left corner (as any windows software). I saw I few methods but they assume I know the namespace and the icon name, but as I told you the form may be used in any application, so I have to find out those informations too... Thanks, Dirso

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Dirso wrote:

      it will get the application icon (if any) and show it in the top left corner

      An application can have many icons, which one do you want?

      Dirso wrote:

      I saw I few methods but they assume I know the namespace and the icon name

      Well, that's because you have to choose between the many potential icons that may exist in your application.

      Dirso wrote:

      as I told you the form may be used in any application

      Actually, you didn't. This is the first time you mentioned that piece of information.

      Recent blog posts: *Method hiding Vs. overriding *Microsoft Surface *SQL Server / Visual Studio install order My Blog

      D 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Dirso wrote:

        it will get the application icon (if any) and show it in the top left corner

        An application can have many icons, which one do you want?

        Dirso wrote:

        I saw I few methods but they assume I know the namespace and the icon name

        Well, that's because you have to choose between the many potential icons that may exist in your application.

        Dirso wrote:

        as I told you the form may be used in any application

        Actually, you didn't. This is the first time you mentioned that piece of information.

        Recent blog posts: *Method hiding Vs. overriding *Microsoft Surface *SQL Server / Visual Studio install order My Blog

        D Offline
        D Offline
        Dirso
        wrote on last edited by
        #3

        Hi, I want the main application icon. That one you choose in the application property window. Thanks, Dirso.

        1 Reply Last reply
        0
        • D Dirso

          Hi, I made a Form derivated class and I'd like to put some code in the Load event so when I use it, it will get the application icon (if any) and show it in the top left corner (as any windows software). I saw I few methods but they assume I know the namespace and the icon name, but as I told you the form may be used in any application, so I have to find out those informations too... Thanks, Dirso

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          Try putting the following code in the constructor for your form. It should pick up the Icon for any app in which it is included. this.Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().Location);

          Henry Minute If you open a can of worms, any valid solution *MUST* involve a larger can!

          D 1 Reply Last reply
          0
          • H Henry Minute

            Try putting the following code in the constructor for your form. It should pick up the Icon for any app in which it is included. this.Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().Location);

            Henry Minute If you open a can of worms, any valid solution *MUST* involve a larger can!

            D Offline
            D Offline
            Dirso
            wrote on last edited by
            #5

            It worked like a charm!!! Thank you 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