Notify Icon for console Application.
I have a console application in C# and i would like to have a notify icon.
Have yet to find an example for it. searched google for "Status Tray Icon for C# console application". ... among others. eg "Console Application Notify Icon forC# ."
Help is much apperciated.
Re: Notify Icon for console Application.
I believe the only way to do it is to add a reference to System.Windows.Forms and declare it as a System.Windows.Forms.NotifyIcon and ContextMenu..
Not exactly a console app once you hit the system tray though, is it ;)
Bill
Re: Notify Icon for console Application.
Yeah. Well...
I guess i could use winForm.
but i really didnt wana.
Also i thought you could use a notify icon with console app's.. at least thats what i've seen done.
Re: Notify Icon for console Application.
Quote:
Originally Posted by PlaGuE
...... at least thats what i've seen done.
Are you sure those apps aren't using any hidden form ?
What i guess from my VB6 experience is, it is impossible to do without a form (window).
My guess is, the .NET framework relies on Win32 API (Shell_NotifyIcon) to display the tray icon. The api expects a NOTIFYICONDATA structure from where it gets a window handle and a callback message to use.
Then, the original window receives the events we perform on trayicon in it's default winproc via that callback message.
VB Code:
' [b]The NOTIFYICONDATA Structure[/b]
Private Type NOTIFYICONDATA
cbSize As Long
hWnd As Long ' It is needed
uId As Long
uFlags As Long
ucallbackMessage As Long
hIcon As Long
szTip As String * 64
End Type