Re: Bubble notifications, HTML buttons and disappearing icon

Further questions inline:

Peter Foot [MVP] wrote:
Answers inline:-


"Erik Mattsson" <erikmattsson_NO-SPAM_@xxxxxxx> wrote in message news:Oys43KIiFHA.1048@xxxxxxxxxxxxxxxxxxxxxxx


Got a couple of problems/questions about the bubble notification things in PPC.
No, although some of the system notifications have images, theres no documented way of doing this through the publicly exposed APIs

Thats a shame, as we want to make nice balloons as well.

2. Is it possible to update the icon through the SHNotificationUpdate() method? I want to update the icon on the tray (when the buble isnt visible), every thime I called the SHNotificationUpdate() with the correct flags it will not update it, I have to remove and then add the notification back again.

This should be possible, when SHNotificationUpdate fails what is the return value? what is the value of GetLastError?

The strange thing was that it returned ERROR_SUCCESS (I think, cant test right now). Is it possible to re-use the struct I used when creating the notification? Or do I have to send in a clean one?

3. What is the LPARAM in the SHNOTIFICATIONDATA struc good for? In the struct I can setup the LPARAM, but why? When I get WM_COMMAND for clicking on a button, it does not have the same LPARAM as I set in the struct.

The lparam is returned in the NMSHN returned by the WM_NOTIFY events

Ok, thanks. Didnt see the value I expected in the LPARAMs, but I will have to check tomorrow.

4. I got an app that need to display a notification that is always accessible. ie, the icon should always reside on the tray. (Clicking on it will show the bubble). I got everything thing setup, I got my three buttons in the bubble, I got a wnd sink listener for the notification struct that listens on WM_COMMAND. The buttons that are in the bubble will close the bubble, but the notification icon (in the tray) disappears as well. Why does it disappear, and what do I do to stop it?

My bubble HTML looks like this:
tmp += L"<input type=button name='cmd:1' value='Cancel 1'>";
tmp += L"<input type=button name='cmd:2' value='Cancel 2'>";
tmp += L"<input type=button name='cmd:55' value='Cancel 55'>";

When I click on button 1, the icon and bubble will disappear.
When I click on button 2, the icon will not disappear, the bubble still disappears as it should BUT I dont get any WM_COMMAND. (Only one WM_NOTIFY, probably because the wnd is closed).
When I click on button 55, the icon and bubble will disappear.

My struct for adding it:
bubbleData.csDuration = -1;
bubbleData.npPriority = SHNP_INFORM ;
bubbleData.hicon = bubbleIcon;
bubbleData.clsid = bubbleGuid;
bubbleData.hwndSink = validHwnd;
bubbleData.pszHTML = bubbleContent;
bubbleData.pszTitle = L"title";
bubbleData.lParam = BUBBLE_LPARAM;
bubbleData.cbStruct = sizeof(SHNOTIFICATIONDATA);

Loads of questions, but I really need some help as I spent too much time on it already. (And googling at the same time)

cmd:2 is a special case as this will dismiss the balloon without raising the response submitted event, for all other cmd:x urls the balloon will be destroyed. In this case you may need to call SHNotificationAdd again after the option is selected.

When you say the balloon, you mean the notification icon that is in the tray as well? Because that is the one I want to keep.
Ok, so I will have to add a new SHNM icon, when Im noticing that the user clicked on a button. Will there be two similar icons in the tray in a brief time? What happens if there is an icon to the left of the first one? Wont the new icon jump to the right of it, ie it will seem that they have switched places?

Im trying to mimic the behaviour of the phone notification (in Phone Edition, for entering flight mode), as I can click the Disconnect button in it, and the icon stays put. I think it will keep its place if there are other icons to right of it. Or have I misunderstood you?

Thanks for your quick answers.