SHNOTIFICATIONDATA

Send Feedback

This structure contains notification data, including notification icon data.

typedef struct _SHNOTIFICATIONDATA{
  DWORD cbStruct;
  DWORD dwID;
  SHNP npPriority;
  DWORD csDuration;
  HICON hicon;
  DWORD grfFlags;
  CLSID clsid;
  HWND hwndSink;
  LPCTSTR pszHTML;
  LPCTSTR pszTitle;
  LPARAM lParam;
  union
  {
    SOFTKEYMENU skm;
    SOFTKEYNOTIFY rgskn[NOTIF_NUM_SOFTKEYS];
  }
  LPCTSTR pszTodaySK;
  LPCTSTR pszTodayExec;
} SHNOTIFICATIONDATA;

Members

  • cbStruct
    Use for verification and versioning.

  • dwID
    Identifier for this particular notification.

  • npPriority
    Priority for the notification. The following table shows the possible priority values.

    Value Description
    SHNP_INFORM Bubble shown for the time in the csDuration parameter.
    SHNP_ICONIC No bubble, icon shown for duration then goes away.
  • csDuration
    Duration of the notification in seconds. The usage depends on the priority.

  • hicon
    Handle to the icon for the notification.

  • grfFlags
    Flag that controls the notification display characteristics. The following table shows the possible flag values.

    Flag Description
    SHNF_STRAIGHTTOTRAY The notification is not displayed when it is initially added. The icon will display for csDuration seconds and will then go straight to the tray. The user can view the icon to see the notification by opening the tray.
    SHNF_CRITICAL The border and title of the notification are highlighted.
    SHNF_FORCEMESSAGE The notification is forced to display, regardless of Settings.
    SHNF_DISPLAYON The display is forced to turn on for the notification.
    SHNF_SILENT The notification is forced to be silent and not vibrate, regardless of Settings.
    SHNF_HASMENU The softkey bar is created from an HMENU passed in skm structure.
    SHNF_TITLETIME The current time is displayed with the notification title.
    SHNF_SPINNERS The notification can be stacked like reminder toasts. The notification will render with left and right arrows in the title. If the pszTitle member contains a tab character, any text after the tab will be rendered between the arrows. For example, "Reminder\t1 of 3".
    SHNF_ALERTONUPDATE Physical alerts are replayed when there is an update to the notification.
    SHNF_WANTVKTTALK The VK_TTALK button is captured and forwarded to the notification's sink window.
  • clsid
    Unique identifier for the notification class.

  • hwndSink
    Handle to the window to receive command choices and dismiss.

  • pszHTML
    HTML content for the notification bubble.

  • pszTitle
    String that contains the optional title for notification bubble.

  • lParam
    User-defined parameter.

  • skm
    SOFTKEYMENU structure that defines a menu for the softkey bar for the notification. The grfFlags member must be set to SHNF_HASMENU if this union type is used.

  • rgskn
    SOFTKEYNOTIFY structure that defines a menu for the softkey bar for the notification, and defines two softkeys.

  • pszTodaySK
    String that contains the text to display on the Today screen for the SK1 softkey. If this string is set to NULL, the default text "Notification" will be displayed.

  • pszTodayExec
    Pointer to the executable that will run when the SK1 softkey is pressed. If this pointer is set to NULL, the toast will be displayed.

Remarks

If the value of grfFlags member is set to SHNF_WANTVKTTALK, and the sink window is a dialog, it must use DWL_MSGRESULT to return the value.

The following code can be added to the sink window's WndProc function to handle the forwarded message.

case WM_NOTIFY:
   switch(wParam)
   {
      case my_dwID:   // the dwID passed into SHNOTIFICATIONDATA when calling SHNotificationAdd
      {
         NMSHN* pnmshn = (NMSHN*)lParam;
         if (pnmshn->hdr.code == SHNN_HOTKEY)
         {
            if (HIWORD(pnmshn->lParam) == VK_TTALK)
            {
               //insert code here to handle VK_TTALK
               //only need to call SetWindowLong if the sinkwindow is a dialog
               SetWindowLong(hWnd, DWL_MSGRESULT, 1);
               //return TRUE to inform the Shell that the button was handled
               return TRUE;
            }
         }
      break;
      }
   }
   break;

The calling application that owns pszHTML, pszTitle, pszTodaySK, pszTodayExec, and skm or rskn must also free the memory when it returns. The following code example illustrates this concept.

void FreeNotificationData(SHNOTIFICATIONDATA * pnd)
{
    LocalFree((HLOCAL)pnd->pszHTML);
    LocalFree((HLOCAL)pnd->pszTitle);
    LocalFree((HLOCAL)pnd->pszTodaySK);
    LocalFree((HLOCAL)pnd->pszTodayExec);

    if (pnd->grfFlags & SHNF_HASMENU)
    {
        LocalFree((HLOCAL)pnd->skm.prgskc);
    }
    else
    {
        LocalFree((HLOCAL)pnd->rgskn[0].pszTitle);
        LocalFree((HLOCAL)pnd->rgskn[1].pszTitle);
    }
}

Requirements

OS Versions: Windows CE 5.01 and later
Header: aygshell.h
Link Library: aygshell.lib

See Also

SHNotificationRemove | SHNotificationAdd | SHNotificationUpdate | SHNotificationGetData

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.