NOTIFYICONDATA (coredll)
Last changed: esquijarosa-167.206.235.141

.
Summary
This structure contains information that the system needs to process taskbar status area messages.

C# Signature:

    public struct NOTIFYICONDATA
    {
        public uint Size;
        public IntPtr HWnd;
        public uint ID;
        public uint Flags;
        public uint CallbackMessage;
        public IntPtr HIcon;
    }

User-Defined Types:

[Flags]

    uint NIF_MESSAGE = 0x01;
    uint NIF_ICON = 0x02;

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

The Sample Code section use the following API's from coredll.dll:

LoadIcon

GetModuleHandle

Shell_NotifyIcon

Tips & Tricks:

Please add some!

Sample Code:

    uint WM_COMMAND = 0x0111;
    uint WM_LBUTTONDOWN = 0x0201;

    uint WM_USER = 0x0400;
    uint WM_NOTIFY_TRAY = WM_USER + 2001;

    public class MessageSink : MessageWindow
    {
        protected override  void WndProc(ref Message m)
        {
            switch(m.Msg)
            {
                case WM_NOTIFY_TRAY:
                    // Check for Tap on our icon (ID 5000)
                    if((uint) m.LParam == WM_LBUTTONDOWN && (uint) m.WParam == 5000)
                    {
                        // Try icon clicked
                        // do something...
                    }
                    break;
                default:
                    base.WndProc(ref m);
                    break;
            }
        }

        public voi ShowIconOnTray()
        {
            // Obtains the app icon (the resource number is fixed for all apps) for the current
            // executing module
            IntPtr hIcon = LoadIcon(GetModuleHandle(null), "#32512");
            // ID for the tray icon (values from 1 to 12 are reserverd by the OS)
            uint uID = 5000;

            NOTIFYICONDATA notdata = new NOTIFYICONDATA();

            notdata.Size = 152;
            notdata.HIcon = hIcon;
            notdata.HWnd = this.Hwnd;
            notdata.CallbackMessage = WM_NOTIFY_TRAY;
            notdata.Flags = NIF_MESSAGE | NIF_ICON;
            notdata.ID = uID;

            Shell_NotifyIcon(NIM_ADD, ref notdata);
        }
    }

Documentation