CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    "bind" icon-file to form/notifyicon

    Hello! I have a form and a notify-icon and both of them have an associated ico-file. When changing the ico-file, you have to go to the properties and choose the icon again in order to make the changes effective.

    Is there any way to tell Visual-Studio to "bind" the icon to the icon-file, so when rebuilding the project the icon refreshes from the file if it has been changed?

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: "bind" icon-file to form/notifyicon

    How about adding the icon as a resource, as described here :

    http://support.microsoft.com/default.aspx/kb/324567

    ¿

    What version of .NET do you have ¿

  3. #3
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    Re: "bind" icon-file to form/notifyicon

    Thanks for your fast reply. The icon was already added to the solution-explorer. So in the Properties Window, I set the build action to "embeded resource" - but still the icon is not changed (even when rebuilding the whole project). Any ideas about that?

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: "bind" icon-file to form/notifyicon

    You see, the whole problem is :
    When you add a resource to your project, a copy is made, and stored in a different place than what it was originally. When you change the file ( where you have last saved it ), the project still has a copy of the old version saved.

    What I want to suggest is to delete the resource from your project, and remove it from the form, and the NotifyIcon, so all references to it. Then, at form load, just set the icon for bot the form as well as the notifyicon through code :
    Code:
            private void Form1_Load(object sender, EventArgs e)
            {
                this.Icon = Icon.ExtractAssociatedIcon("Adriaan.ico");
                notifyIcon1.Icon = Icon.ExtractAssociatedIcon("Adriaan.ico");
            }
    I hope my info was helpful!

  5. #5
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    Re: "bind" icon-file to form/notifyicon

    Thanks again for your reply. But when I use ExtractAssociatedIcon and distribute the application I would have to add the icon-files, right? That would be a disadvantage.

    You say that a copy is made - where is this copy stored? Because I couldn't find it. But if I could locate it I could just edit the copy to take effect in the next build.

  6. #6
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: "bind" icon-file to form/notifyicon

    Quote Originally Posted by martho View Post
    Thanks again for your reply. But when I use ExtractAssociatedIcon and distribute the application I would have to add the icon-files, right? That would be a disadvantage.
    Well, it is part of your project, a resource then would also be a disadvantage. Icon files are small in size. But still, I agree not having it deployed with, because it may get deleted etc. Will the icon file change often ¿ Or is it just now that its changing so much ¿

    Quote Originally Posted by martho View Post
    You say that a copy is made - where is this copy stored? Because I couldn't find it.
    Mine is stored inside my solution folder, where you see the .csproj and cs files.

    Quote Originally Posted by martho View Post
    But if I could locate it I could just edit the copy to take effect in the next build.
    That may also not work

  7. #7
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    Re: "bind" icon-file to form/notifyicon

    Quote Originally Posted by HanneSThEGreaT View Post
    Well, it is part of your project, a resource then would also be a disadvantage. Icon files are small in size. But still, I agree not having it deployed with, because it may get deleted etc. Will the icon file change often ¿ Or is it just now that its changing so much ¿
    It's just while developing you see that the icon doesn't fit, so you change it, and I want to see the result quickly - and it drives you crazy to set the icon every time.

    Quote Originally Posted by HanneSThEGreaT View Post
    Mine is stored inside my solution folder, where you see the .csproj and cs files.
    Mine, too...

  8. #8
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: "bind" icon-file to form/notifyicon

    Quote Originally Posted by martho View Post
    It's just while developing you see that the icon doesn't fit, so you change it, and I want to see the result quickly - and it drives you crazy to set the icon every time.
    Yep, True words!
    It's usually the small things that give the biggest headaches! LOL!

  9. #9
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    Re: "bind" icon-file to form/notifyicon

    Thanks a lot - it helps to see someone suffering just the same ;-)

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