A few days ago, a netizen asked. NET CF how to implement NotifyIcon, I just know the original. NET CF does not provide a NotifyIcon control.
So I think the PC can use Shell_NotifyIcon and MessageWindow to implement the tray icon, just do not know. NET CF Support does not support these two things. Take a closer look at the suspicious namespaces in the. NET CF, and unexpectedly there is a MessageWindow class inside the Microsoft.WindowsCE.Forms namespace, so good that there is only one Shell_NotifyIcon function left. Then in the Windows CE SDK Help file, also found that the window CE Platform API already contains the Shell_NotifyIcon function. The two major "ingredients" are all together, only the pot left.
First look at the MessageWindow class, which provides a WndProc method for processing window messages and exposes valid window handles that may be passed to the native window function. To use it, derive a new class and rewrite the WndProc method so that you can intercept specific window messages. This is primarily used to handle click events.
The use of Shell_NotifyIcon is as follows:
[DllImport ("Coredll.dll")]
internal static extern int Shell_NotifyIcon (int dwmessage, ref notifyicondata Pnid);
Among them, the NOTIFYICONDATA structure is as follows:
struct NOTIFYICONDATA
{
int cbSize;
IntPtr hWnd;
uint uID;
uint uFlags;
uint uCallbackMessage;
IntPtr hIcon;
}
The life of the Pnid parameter needs to be noted and passed by reference because Shell_NotifyIcon requires a pointer to the NOTIFYICONDATA structure.
An HWND is a handle to a window that receives an icon in the taskbar to click a message.
When running the example, because the form is maximized, the taskbar is blocked, and the tray icon is visible after the form is minimized. (The effect picture unexpectedly pastes not to come up, another day pastes bar)
Download address for this class and example: Http://www.cnblogs.com/Files/ttinfo/NotifyIconCf.rar