Results 1 to 11 of 11

Thread: VB.NET - notifyIcon .

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,086

    VB.NET - notifyIcon .

    How to put icon in the system tray when you click "X" button on your form .
    Attached Files Attached Files

  2. #2
    Lively Member
    Join Date
    Jul 2003
    Posts
    90
    Thanks Pirate! I have one question, I have the need to change the icon based on the status of the app. How do I change the icon progammatically? That property does not have the "FromFile" method like an image property.

    Thanks again for the code.

  3. #3
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    like this ....
    VB Code:
    1. Dim ico As New Icon("C:\someicon.ico") '/// path of your icon.
    2.         ni.Icon = ico '/// set the icon to your notify icon ( where your notify icon's name would be inplace of ni )
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  4. #4

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,086
    Originally posted by jstansell
    Thanks Pirate! I have one question, I have the need to change the icon based on the status of the app. How do I change the icon progammatically? That property does not have the "FromFile" method like an image property.
    Thanks again for the code.
    dynamic_sysop got your back .

  5. #5
    Lively Member
    Join Date
    Jul 2003
    Posts
    90
    That worked. Thanks for you help!!

  6. #6
    Hyperactive Member
    Join Date
    Jul 2004
    Location
    Kansas, USA
    Posts
    352
    Pirate:
    Thanks for the example. Is there a way that you can see that I could do the same thing using the minimize thingie (technical term) two elements to the left of the X box?

    Also, is the only way to kill this app from the task list?

    Thanks,
    Eric
    Thanks,
    Eric
    --------------------------------------------------------------------------------------------------------------------
    VB.net/C# ... Visual Studio 2019
    "None of us are as smart as all of us."

  7. #7
    Addicted Member Codehammer's Avatar
    Join Date
    Aug 2004
    Posts
    164

    Re: VB.NET - notifyIcon .

    Note, Editing the Forms Closing Event Will to Minimize will cause this to Fire when a Shutdown or Forceshutdown is executed, meaning your computer wont Shutdown until the App is Closed by a Application.exit somewhere else.
    Curiosity SKILLED the cat
    Google Talk from your Mobile phone

    Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2

  8. #8
    Lively Member technicalItch's Avatar
    Join Date
    Nov 2005
    Location
    England, UK
    Posts
    74

    Re: VB.NET - notifyIcon .

    Thats very good. Is there any way it could be adapted for a .aspx vb.net page? When the user clicks the X on their browser it has the same effect?

  9. #9

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,086
    Quote Originally Posted by technicalItch
    Thats very good. Is there any way it could be adapted for a .aspx vb.net page? When the user clicks the X on their browser it has the same effect?
    Not without client-side script,I believe.

  10. #10
    Lively Member polecat's Avatar
    Join Date
    Jul 2005
    Location
    Wolverhampton
    Posts
    83

    Re: VB.NET - notifyIcon .

    Hi flycast

    I use this to handle minimize and left click as i have context menu on the
    right click

    VB Code:
    1. Private Sub mainForm_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
    2.         If Me.WindowState = FormWindowState.Minimized Then
    3.             NotifyIcon1.Visible = True
    4.             Me.Visible = False
    5.         End If
    6.     End Sub
    7.  
    8.  
    9.     Private Sub NotifyIcon1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDown
    10.         If e.Button = Windows.Forms.MouseButtons.Left Then
    11.             Me.Visible = True
    12.             If Me.WindowState = FormWindowState.Minimized Then
    13.                 Me.WindowState = FormWindowState.Normal
    14.             End If
    15.             NotifyIcon1.Visible = False
    16.         End If
    17.     End Sub

    Hope you dont mind me putting this here !

  11. #11

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,086

    Re: VB.NET - notifyIcon .

    That's alright dude...This thread is almost 3 years old

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