Notify Icon not being displayed

G

Guest

hi, im using this code to display a notifyicon object with information
provided at runtime

Protected Overrides Sub WndProc(ByRef m As Message)

MyBase.WndProc(m)

If m.Msg = WM_SYSCOMMAND Then

Select Case m.WParam.ToInt32

Case 1000

Dim tray As New NotifyIcon

tray.Icon = Icon.FromHandle(m.HWnd)
tray.Visible = True

AddHandler tray.DoubleClick, AddressOf
NotifyIcon1_DoubleClick

SendMessage(m.HWnd.ToInt32, 0, Nothing, Nothing)

End Select

End If

End Sub


what i am attempting to do is recreate a project i saw on CodeProject where
you add a menu "Tray Me" to the System menu and when a user clicks on it, the
window is hidden and an icon is displayed, yet this doesnt work....any help
would be great, thanks
 
T

tomb

You might want to try declaring tray as NotifyIcon in the form
declarations, rather than as a local variable.

T
 
G

Guest

i have tried declaring it locally and globally and neither work. I am
attempting to create a program that will be able to put any application in
the system tray....so i need to make a NotifyIcon at run time......any
suggestions would be great, thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top