Results 1 to 5 of 5

Thread: Icon

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    155

    Icon

    Can anyone tell me what is wrong with this code ?

    m_notifyicon.Icon = new Icon(this.GetType() ,"Icon1.ico");

    I have this error' Icon1.ico not found in class "Win..."

    Resource

    Thanks

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Icon

    Did you set the icons property to Embedded resource instead of Content?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    155

    Re: Icon

    Quote Originally Posted by RobDog888
    Did you set the icons property to Embedded resource instead of Content?

    Yes, I did . But If I change the code to this

    Code:
    m_notifyicon.Icon = new System.Drawing.Icon(@"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\WindowsApplication6\WindowsApplication6\Icon1.ico");
    It work. But I would like to understand why?


    Thanks

  4. #4
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: Icon

    You didn't import the correct classes.

    At the top of the class file you should have added
    vb Code:
    1. using System.Drawing;

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Icon

    If you pass this.GetType() as the first parameter you're specifying that the icon is an embedded resource belonging to the current class. In your second sample you're not doing that.

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