locked
Add a Taskbar icon, but without the "Notification" Softkey? RRS feed

  • Question

  • Hello,

    I'm trying to add an icon to the Taskbar, but not as a Notification icon, more as a "specific use" icon. It seems as though the recommended way to display a taskbar icon is to use SHNotificationAdd(). However, everytime I use it, the Left Softkey (on the Today screen) is replaced with "Notification." I would like to prevent this "Notification" text from taking over the Left Softkey.

    So, my question is this: Is there any way to keep the original Today screen Left Softkey menu item ("Calendar," by default)?

    I've seen this done by the Volume, ActiveSync, and WiFi/Connectivity icons. It would be interesting to know how Microsoft does it...

    Here are the ideas I have so far for this:

    1) Not using the SHNotificationAdd() function and creating a window that just sits on top of the Taskbar, as mentioned at http://social.msdn.microsoft.com/Forums/en-US/windowsmobiledev/thread/a13a2a9e-7948-4033-be3b-0833c028b1c4/#

     -- With this, wouldn't I have to detect where there is free space available for the icon? Or, does making it a Child of the Taskbar automatically position the icon next to the others?

    2) Before calling SHNotificationAdd(), retrieving the Today screen's Left Softkey menu item information (Text and command). Then immediately after the SHNotificationAdd() call, restoring the original setting.

     -- However, this may be a bit tricky; and I'm not even sure if it's possible to retrieve the menu's "command."

    3) Calling SHNotificationAdd() and somehow dismissing the Notification, while keeping the icon displayed.

     -- I don't know if this is possible though.


    I've searched the newsgroups and the web, and I've seen a bunch of people asking about this but no solutions have been posted yet, apart from the one in the above link. I'm wondering if there are any other possible solutions?

    The code that I'm currently using is pretty much the same as what's found on the MSDN SHNotificationAdd() page (http://msdn.microsoft.com/en-us/library/aa455967.aspx).

    (I'm using Native C++, with WM 2003 and up, by the way. I've managed to get SHNotificationAdd() to work on WM 2003 by making my own SHNOTIFICATIONDATA struct that includes the missing .rgskn member, and then casting the custom SHNOTIFICATIONDATA struct to "SHNOTIFICATIONDATA" when calling SHNotificationAdd().)

    Any ideas? Any help would be greatly appreciated.

    Thank you very much,
    Michael Prendergast
    Monday, March 23, 2009 4:12 AM

Answers

  • Hi Michael,

    It is against the Windows Mobile Guidelines to add your icon into the taskbar:

    Quote: " Required: No Information Added to Title Bar
    Applications cannot add additional icons to the title bar. It is permissible to replace the application title in the title bar with context-specific information. For example, the agenda view in calendar shows the date in the title bar instead of ―Calendar"

    So I don't think you can find an API to do that but go for some tricks which are not recommended.

    Regards,
    Chunsheng Tang
    Please mark the post that helps you, and unmark that does not. This benefits our community members.
    • Marked as answer by warrentang Friday, March 27, 2009 1:58 AM
    Thursday, March 26, 2009 8:03 AM
  • I recently investigated this problem again, and found that to display the notification icon on the taskbar and the message on top, we can specify the following GUID to SHNotificationAdd:

    {0x99de7411, 0x772f, 0x43d0, { 0x81, 0xf0, 0x66, 0x83, 0x36, 0xca, 0x65, 0x1b }}

    However I didn't find any document about this, so I am not sure about the risks of using this approach. Here is the sample code (I've tested it in Windows Mobile 6 and 6.5 Pro emulators): 

    static const GUID CLSID_SHNAPI_Test = {0x99de7411, 0x772f, 0x43d0, { 0x81, 0xf0, 0x66, 0x83, 0x36, 0xca, 0x65, 0x1b }};

        // This code will add an SHNotificaion notificaion (PocketPC only)
        SHNOTIFICATIONDATA sn  = {0};
        SHNOTIFICATIONDATA sn2 = {0};

        sn.cbStruct = sizeof(sn);
        sn.dwID = 1;
        sn.npPriority = SHNP_INFORM;
        sn.csDuration = 15;
        sn.hicon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_WIN32PROJ));
        sn.clsid = CLSID_SHNAPI_Test;
        sn.grfFlags = 0;
        sn.pszTitle = TEXT("Sample Notification");
        sn.pszHTML = TEXT("<html><body>This is <b>sample html</b> in a notification!</body></html>");
        sn.rgskn[0].pszTitle = TEXT("Dismiss");
        sn.rgskn[0].skc.wpCmd = 100;

        //Add the notification to the tray
        SHNotificationAdd(&sn);

        
        //Remove the notification from the tray
        SHNotificationRemove(&CLSID_SHNAPI_Test, 1);


    Please mark the post that helps you, and unmark that does not. This benefits our community.
    • Marked as answer by warrentang Tuesday, May 18, 2010 6:18 AM
    Monday, December 7, 2009 6:54 AM

All replies

  • Hi Michael,

    It is against the Windows Mobile Guidelines to add your icon into the taskbar:

    Quote: " Required: No Information Added to Title Bar
    Applications cannot add additional icons to the title bar. It is permissible to replace the application title in the title bar with context-specific information. For example, the agenda view in calendar shows the date in the title bar instead of ―Calendar"

    So I don't think you can find an API to do that but go for some tricks which are not recommended.

    Regards,
    Chunsheng Tang
    Please mark the post that helps you, and unmark that does not. This benefits our community members.
    • Marked as answer by warrentang Friday, March 27, 2009 1:58 AM
    Thursday, March 26, 2009 8:03 AM
  • I recently investigated this problem again, and found that to display the notification icon on the taskbar and the message on top, we can specify the following GUID to SHNotificationAdd:

    {0x99de7411, 0x772f, 0x43d0, { 0x81, 0xf0, 0x66, 0x83, 0x36, 0xca, 0x65, 0x1b }}

    However I didn't find any document about this, so I am not sure about the risks of using this approach. Here is the sample code (I've tested it in Windows Mobile 6 and 6.5 Pro emulators): 

    static const GUID CLSID_SHNAPI_Test = {0x99de7411, 0x772f, 0x43d0, { 0x81, 0xf0, 0x66, 0x83, 0x36, 0xca, 0x65, 0x1b }};

        // This code will add an SHNotificaion notificaion (PocketPC only)
        SHNOTIFICATIONDATA sn  = {0};
        SHNOTIFICATIONDATA sn2 = {0};

        sn.cbStruct = sizeof(sn);
        sn.dwID = 1;
        sn.npPriority = SHNP_INFORM;
        sn.csDuration = 15;
        sn.hicon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_WIN32PROJ));
        sn.clsid = CLSID_SHNAPI_Test;
        sn.grfFlags = 0;
        sn.pszTitle = TEXT("Sample Notification");
        sn.pszHTML = TEXT("<html><body>This is <b>sample html</b> in a notification!</body></html>");
        sn.rgskn[0].pszTitle = TEXT("Dismiss");
        sn.rgskn[0].skc.wpCmd = 100;

        //Add the notification to the tray
        SHNotificationAdd(&sn);

        
        //Remove the notification from the tray
        SHNotificationRemove(&CLSID_SHNAPI_Test, 1);


    Please mark the post that helps you, and unmark that does not. This benefits our community.
    • Marked as answer by warrentang Tuesday, May 18, 2010 6:18 AM
    Monday, December 7, 2009 6:54 AM