Aximili


Hi,

How do I implement one or both buttons of the notification balloon created using .NET CF (Microsoft.WindowsCE.Forms.Notification)

At least I would like a Dismiss button like the normal notification, without having to do it in the HTML.

Thank you in advance.


Re: Notification buttons

Christopher Fairbairn


Hi,

Aximili wrote:
How do I implement one or both buttons of the notification balloon created using .NET CF (Microsoft.WindowsCE.Forms.Notification)

At least I would like a Dismiss button like the normal notification, without having to do it in the HTML.

The Microsoft.WindowsCE.Forms.Notification class is a wrapper over a native system API called

SHNotificationAdd (http://msdn2.microsoft.com/en-us/library/aa458064.aspx). It does not expose all the functonality of the operating system control.

On Windows Mobile 5.0 or higher devices the SHNotificationAdd API was extended to support custom menu bars or soft keys to be associated with a notification (for example when you receive a SMS text message, you can click a soft key to open the message).

At present you would need to manually PInvoke the SHNotificationAdd API in order to get custom buttons on your notifications. The structure you pass to this API has a couple of additional fields on WM5.0 or higher devices which control the soft key buttons.

I am actually in the process of tidying up a sample application which demonstrates doing this to post to my blog. I will try to do this in the next day or two so I can give you a code example.

Hope this helps, sorry I don't have a concrete solution at this point in time.

Christopher Fairbairn






Re: Notification buttons

Aximili

Thank you Chris. If it is too hard may be I'll just stick to the default Hide button Stick out tongue
But I'll be interested in the sample application u're creating. Thanks! :-D





Re: Notification buttons

Christopher Fairbairn

Hi,

Aximili wrote:
Thank you Chris. If it is too hard may be I'll just stick to the default Hide button
But I'll be interested in the sample application u're creating. Thanks! :-D

I have posted the blog entry I dicussed earlier. It is titled "Custom soft keys for Notifications" and is available at http://www.christec.co.nz/blog/archives/150

Here is a sample screenshot of the kind of thing which is possible using this wrapper

The custom class I wrote (NotificationWithSoftKeys) is designed as drop in replacement for the standard Microsoft.WindowsCE.Forms.Notification class. It simply has a couple of additional properties to configure the Left and Right Soft Key functionality as demonstrated in the following code sample.

Code Block
private NotificationWithSoftKeys notification;

private void btnCreateNotification_Click(object sender, EventArgs e)
{
notification = new NotificationWithSoftKeys();
notification.Icon = Properties.Resources.Icon;
notification.Caption = "This is my notification";
notification.Text = "A soft key test";
notification.LeftSoftKey =
new NotificationSoftKey(SoftKeyType.Dismiss, "Close");
notification.RightSoftKey =
new NotificationSoftKey(SoftKeyType.StayOpen, "View");
notification.RightSoftKeyClick +=
new EventHandler(notification_rightSoftKeyClick);
}

notification.Visible = true;
}

As with all sample code there may be rough edges etc, hopefully however the sample demonstrates one possible solution solution to this issue, and gets you started down the right track if you choose to use custom soft keys.

Hope it helps,

Christopher Fairbairn






Re: Notification buttons

Aximili

Wow.. much much better than I expected.
It's perfect! Thanks a lot Christopher!