Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

NOTIFYICONDATA (coredll)
 

coredll is for smart devices, not desktop Windows. Therefore, this information only applies to code using the .NET Compact Framework. To see if information for NOTIFYICONDATA in other DLLs exists, click on Find References to the right.

.
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

None.

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");
            // Obtains the app icon (the resource number is fixed for all apps)
            IntPtr hIcon = LoadIcon(GetModule(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

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions