Results 1 to 5 of 5

Thread: System tray icon Error

  1. #1

    Thread Starter
    Lively Member smilbuta's Avatar
    Join Date
    Apr 2005
    Location
    Orlando
    Posts
    104

    System tray icon Error

    I am trying to add an icon to a system tray item.

    when i type in the sample code im working from i get an error at this line.


    VB Code:
    1. Me.NotifyIcon1.Icon = CType([B][U]Resources.getObject[/U][/B]("NotifyIcon1.Icon"), System.Drawing.Icon)

    The bold undeline tells me GetObject not a member of resources. THe code is exactly as it appears in my book. Im unsure what im missing..

    The over all project is a form witha button, click button and make a system tray icon while hiding form.

    Any help would be apreciated.

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: System tray icon Error

    Which version are you using?

  3. #3
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: System tray icon Error

    Ok, I am assuming you are using 2002 or 2003, so below is an example that should load the icon file as long as it is an item in your project, and you changed the icon file to be an embedded resource in the build action.
    VB Code:
    1. Me.NotifyIcon1.Icon = New Icon( _
    2.             System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream( _
    3.             "MyApp.myicon.ico"))
    Replace the ""MyApp" string with your project name, and the "myicon.ico" with the name of your icon file, and it is case sensitive.

    In 2005, you can just access the My.Resources object...

  4. #4

    Thread Starter
    Lively Member smilbuta's Avatar
    Join Date
    Apr 2005
    Location
    Orlando
    Posts
    104

    Re: System tray icon Error

    Sorry i should have stated im using 2005. Perhaps its the fact that im using a 2003 book as refrence.. It works now... thank you.

  5. #5
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: System tray icon Error

    WEll it should be easier in 2005. Just check out the project properties (right click project, go to properties), and theres a Resources section. You just add your icon to that, and then refer to it using My.Resources...

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