Results 1 to 4 of 4

Thread: Notify Icon for console Application.

  1. #1

    Thread Starter
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    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.
    Without balance, there could only be chaos.
    Without chaos, there could be no balance.
    I live with karma. Eat with destiny. Dream of life without shackles....
    Yet. If life had no consequences, life could not exist, nor could it flourish.


    If at first you dont succeed.You're screwed.

    C++/Java NOOB.

    I aint a professional at PHP, but if i can help i will.

  2. #2
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    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
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  3. #3

    Thread Starter
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    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.
    Without balance, there could only be chaos.
    Without chaos, there could be no balance.
    I live with karma. Eat with destiny. Dream of life without shackles....
    Yet. If life had no consequences, life could not exist, nor could it flourish.


    If at first you dont succeed.You're screwed.

    C++/Java NOOB.

    I aint a professional at PHP, but if i can help i will.

  4. #4
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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:
    1. ' [b]The NOTIFYICONDATA Structure[/b]
    2.  
    3. Private Type NOTIFYICONDATA
    4.     cbSize As Long
    5.     hWnd As Long ' It is needed
    6.     uId As Long
    7.     uFlags As Long
    8.     ucallbackMessage As Long
    9.     hIcon As Long
    10.     szTip As String * 64
    11. End Type
    Last edited by iPrank; Mar 26th, 2006 at 11:43 AM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


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