New Notification API in Pocket PC 2002

xiaoxiao2021-03-06  45

New Notification API in Pocket PC 2002

Microsoft Corporation

June 2002

Summary: Describes the New Notification API of Pocket PC 2002, Which Allows Your Application To Send Notification To The Top of The Visible Screen. (5 Printed Pages)

Applies TO: Microsoft® Windows® Powered Pocket PC 2002 Microsoft Embedded Visual Tools Version 3.0 Pocket PC 2002 Software Development Kit

Gotchas

The Notification API is not part of Microsoft Messenger. This means if you have subscribed to Microsoft .NET Alerts you will not get the notification automatically in Messenger. Microsoft Messenger uses the Notification API to display incoming chat request and text during a chat session.

Contents

Why notifications? Introducing the notification apistep 1: adding a simple notificationstep 2: Receiving Notifications from the NotificationConclusion

Why notifications?

You are probably as addicted to Instant Messaging * as I am. You immediately look to the corner of the screen that shows you if one of your buddies has logged on or if someone has sent you an instant message. Well, the heart of Instant Messaging And especially the little "toast" That Shows Up, IS A Notification System. by Definition a Notification IS A Little Message That Pops Up on The Screen No Matter What You Are Doing Or What Application Has The Window Focus.

Starting with the idea of ​​Instant Messaging you can imagine all sorts of interesting usages for notifications: incoming phone calls, incoming e-mails, incoming messages, stock quote updates, downloads of complete messages, alerts of critical states in your application, and so on WHILE IN PC 2002 and You Will Encounter The Up To US, THE DEVELOPERS, TO CREATE.FIGURE 1. A Sample "New Mail" Notification

Introducing the Notification API

Pocket PC 2002 is a great communication platform. To qualify for a great communication platform, at least in my eyes, it has to support notifications. The new Notification API included in Pocket PC 2002 has everything to create exiting applications that benefit from notifications. The notification system is intended for applications that are not in the foreground in order to notify the user of some activity without stealing the context of which the user is in at that moment. It is nOT a replacement for message box or Information Dialog, which request general Information During the Use of an Application.

The application programming interface (API) consists of a series of calls all starting with "SH ..." because they belong to the family of Shell-APIs The three most important calls are:. SHNotificationAdd-to add a new notification to the notification Subsystem of the pocket pc shell; shNotificationRemove-to remove it again; and shNotificationUpdate-to update a notification.

I assembled a short list of step to show you what needed to be done to include the appi in your application.

Step 1: Add a Simple Notification

The following codes show how you can add a simple notification to your application. As you can see you can even send well-formatted HTML as a notification. Even form fields and hyperlinks are shown correctly. # Include "stdafx.h"

#include

#include "resource.h"

#define ids_defaulttitle text ("Sample Notification ...")

#define ids_defaulthtmlMessage text ("

HREF = / "cmd: 11 /"> Test Link

this is an

Color = / "# 0000ff /">

html Notification Stored in A

Color = / "# ff0000 /"> String

Table!

Value = 'ok'>

");

// GUID for the app please cagculate your OWN!

// {CA777AF7-3CDE-4C15-A7CD-81F629ABA6B8}

Static const guid guidppcalertsapp =

{0xCA777AF7, 0x3cde, 0x4c15, {0xA7, 0xcd, 0x81, 0xf6, 0x29, 0xAb,

0xA6, 0xB8}};

Int WinApi Winmain (Hinstance Hinstance,

Hinstance Hprevinstance,

LPTSTR LPCMDLINE,

INT ncmdshow)

{

ShNotificationData * pcurrentnotification = null;

Hicon Hicon = NULL;

// idi_message icon Has to be created in the resourcesã ...

Hicon = (Hicon) loadImage (Hinstance, MakeintResource (IDI_MESSAGE),

Image_ICON, 16, 16, LR_DEFAULTCOLOR

PcurrentNotification = (ShNotificationData *) Malloc

SIZEOF (SHNOTIFICATIONDATA);

PcurrentNotification-> dwid = 4711;

PcurrentNotification-> CLSID = guidppcalertsapp; pcurrentnotification-> nppriority = shnp_inform;

PcurrentNotification-> csduration = 20;

PcurrentNotification-> hwndsink = null;

PcurrentNotification-> pszhtml = IDS_DEFAULTHTMLMESSAGE;

Pcurrentnotification-> hicon = hic;

PcurrentNotification-> Cbstruct = SizeOf (ShNotificationData);

PcurrentNotification-> psztitle = IDS_DEFAULTTITLE;

PcurrentNotification-> grfflags = null;

ShNotificationAdd (PcurrentNotification);

// We Just Wait for 30 Second Before We Remove The Notification Again

SLEEP (30000);

ShNotificationRemove (& GuidppCalertsapp, 4711);

Return 0;

}

IF you start this application it will show a sample notification as seen in the figure.

Step 2: Receiving Notifications from the Notification

Sending a Notification Has One Major Purpose for An Application: TO BRING The User Back to the Application! Seen by a developer, this can only be used by the application is notified by the noteification.

Here Are The Steps To Get a Notification In Your Application WHEN A User Taps on a Link in The Notification Window.

Step 2a: add The hwnd of your main windows.

PcurrentNotification-> hwndsink = hwnd;

Step 2b: Add a Case Branch To Your WM_Command Processing Parsing for the Number In The Href "CMD: 11" and "cmd: 10" in the previous example.

DONE! SIMPLE, ISN 'ket?

Conclusion

The Notification API is simple and powerful at the same time. For more detailed information about the parameters and structure members of the API, please consult the SDK documentation. The SDK also includes a great example named "NotifyMFC" that shows the full power of the NOTIFICATION API. * Use of some functionality Contained in The Software May Require A Separately Purchased Modem or Other Wireless Accessory. See Pocket PC DeTails.

转载请注明原文地址:https://www.9cbs.com/read-78956.html

New Post(0)