/// <summary> /// Displays a message balloon with a dismiss button. /// </summary> /// <param name="id"></param> /// <param name="title"></param> /// <param name="text"></param> /// <param name="showTime"></param> /// <param name="icon"></param> public static void Show(Guid id, string title, string text, bool showTime, Icon icon) { if (id == null) { id = Guid.NewGuid(); } else { try { SHNotificationRemove(ref id, 0); } catch { } } if (icon == null) { throw new ArgumentNullException("icon"); } data = new SHNOTIFICATIONDATA(); if (PlatformSupportsCustomSoftKeyButtons) { data.cbStruct = Marshal.SizeOf(data); } else { data.cbStruct = Marshal.SizeOf(data) - 32; // "hide" the 20 bytes that were added to this struct in WM5.0 } data.clsid = id; data.dwID = 0; //r.Next(0, 10000); data.csDuration = 10; data.hicon = icon.Handle; data.pszTitle = title; data.pszHTML = text; data.npPriority = SHNP.INFORM; if (showTime) { data.grfFlags |= SHNF.TITLETIME; } if (PlatformSupportsCustomSoftKeyButtons) { data.leftSoftKey.pszTitle = " "; data.leftSoftKey.skc.grfFlags = (uint)SoftKeyType.Disabled; data.leftSoftKey.skc.wpCmd = (uint)(data.dwID << 8); data.rightSoftKey.pszTitle = "Dismiss"; data.rightSoftKey.skc.grfFlags = (uint)SoftKeyType.Dismiss; data.rightSoftKey.skc.wpCmd = (uint)(data.dwID << 8) + 1; } SHNotificationAdd(ref data); }
/// <summary> /// Initializes a new instance of the <see cref="Notification"/> class. /// </summary> /// <remarks>This class is not supported on the Smartphone or other Windows CE devices that are not Pocket PCs. /// You can create multiple notifications, such as an array of notifications, and display them as needed with the Visible property.</remarks> public NotificationWithSoftKeys() { m_data = new SHNOTIFICATIONDATA(); if (PlatformSupportsCustomSoftKeyButtons) { m_data.cbStruct = Marshal.SizeOf(m_data); } else { m_data.cbStruct = Marshal.SizeOf(m_data) - 32; // "hide" the 20 bytes that were added to this struct in WM5.0 } m_data.clsid = Guid.NewGuid(); m_data.dwID = id; m_data.hwndSink = msgwnd.Hwnd; m_data.csDuration = 10; notifications.Add(id, this); id++; }
private static extern int SHNotificationGetData(ref Guid clsid, int dwID, ref SHNOTIFICATIONDATA shinfo);
private static extern int SHNotificationUpdate(SHNUM grnumUpdateMask, ref SHNOTIFICATIONDATA shinfo);
private static extern int SHNotificationAdd(ref SHNOTIFICATIONDATA shinfo);