Using C # to implement NotifyIcon classes on smart devices

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.