When developing SmartPhone / Pocket PC applications with .NET CF, we often need to add a reminder feature to applications, such as at two o'clock in the afternoon, remind users to meet, or remind users to synchronize an important importance when handheld devices and PCs. data. At present, the reminder function mainly has the following ways:
Windows CE .NET provides CESETUSERNOTIFICATION (in CE 2.11 version and later adding CesetUserNotificationEx) this API, which can be used to create or modify a reminder. This method is applicable to Smartphone and Pocket PC. Windows CE .NET also provides an additional API, ShNotificationAdd, or a reminder work. This reminder is displayed in the spark method in the Pocket PC, and does not process on the SmartPhone. Pocket Outlook is built in Windows CE .NET and provides Poom (Pocket Outlook Object Model) for secondary development. This method is applicable to Smartphone and Pocket PC.
The above three methods are developed at different degrees to use platform calls or COM interoperability, which is very high for developers, and it is not conducive to improving development speed. Therefore, the appropriate packaging is very necessary. Fortunately, the current OpenNetcf.org (http://www.opennetcf.org) has completed the first two work, and the previous two APIs have been made in SDF (Smart Device Framework) developed by Opennetcf and distributed. Encapsulated as a Managed API, greatly reduced the difficulty of developers' second development. At the same time, INTHEHAND (http://www.inthehand.com) also provides a great component -Pocket Outlook, encapsulated underground COM interoperability with Managed Code, making developers from tight underlying details Get rid of it. However, INTHEHAND includes only free test plates, if you need to use it in business environments.
Below I will explain the application of the above methods through a series of instances.
Opennetcf.win32.notify
Opennetcf.org encapsulated CESetUserNotification under the opennetcf.win32.notify namespace in SDF, and only a few lines of code can implement simple reminder after use, such as the next example, you can be in SmartPhone / Pocket PC 2003 sets a reminder dialog box after 1 minute (you need to add a reference to OpenNetcf.dll):
UserNotification Notification = New UserNotification ();
NOTIFICATION.ACTION = NOTIFICATIONAALOG;
Notification.title = "My Reminder";
NOTIFICATION.TEXT = "Don't forget to exercise!"
Notify.setUserNotification ("", DateTime.now.addminutes (1), Notification;
The effect is as follows:
Figure 1: Effect of OpenNetcf.win32.notify on SmartPhone
Figure 2: Effect of OpenNetcf.win32.notify on Pocket PC
If you want to modify a reminder, simply call NOTIFY.GetUserNotificationHandles returns a handle (Handle) stored by all current system, then use the specific handle to call Notify.getUserNotification, you can get the corresponding reminder object, call notify.setUserNotification) To modify this reminder. For example, in the case, make changes the reminder of the previously set: // Get a reminder object (UserNotificationInfoHeader type)
UserNotificationInfoHeader InfoHeader =? NOTIFY.GETUSERNOTIFICATION (HANDLE);
/ / Remove the UserNotification section and make changes
UserNotification NOTIFICATION = InfoHeader.userNotification;
IF (Notification! = NULL)
{
Notification.text = "Don't forget the meeting!"
Notify.setUserNotification (Handle, ", DateTime.Now.Addseconds (18), Notification;
}
2. Opennetcf.notification
The above method also takes effect on Smartphone 2003 and Pocket PC 2003. For Pocket PC 2003, there is another way to set a reminder-pop-up bubble. The method API corresponding to this method is ShNotificationAdd, which is encapsulated under the OpenNetcf.notification namespace in the SDF. The following code demonstrates this use (you need to add a reference to OpenNetcf.notification.dll):
NOTIN NOTIFICATION = New Notification ();
NOTIFICATION.DURATION = 10;
NOTIFICATION.FLAGS = NOTIFICATIONFLAGS.FORCEMESSAGE;
NOTIFICATION.html = "Hello Windows Mobile";
NOTIFICATION.TITLE = "hi";
NotificationEngine Engine = New NotificationEngine (OpenNetcf.Security.cryptography.NativeMethods.guid.newguid ());
Engine.Add (Notification);
Note that this is increasing a bubble reminder by calling the NotificationsEngine.Add () method to the trailer (TRAY).
Figure 3: Applying NotificationEngine.Add in Pocket PC
Similarly, we can delete a reminder by calling notificationEngine.remove, NotificationEngine.Update to update a reminder, NotificationEngine.getdata method to get a reminder. They packaged system APIs are ShNotificationRemove, ShNotificationUpdate, and ShNotificationgetData, respectively.
3. INTHEHAND.POCKETOUTLOOK
With Inthehand Package PocketOutlook DLL, we can easily use the powerful features provided by Pocket Outlook. For example, the following example demonstrates how to add a date in this machine's Pocket Outlook, you can use a similar approach to add contacts, schedule information, etc. (you need to add Inthehand.interop.dll and Inthehand. PocketOutlook.dll's references): use (OutlookApplication OAPP = New OutlookApplication ())
{
USING (Appointment OAPTMT = OAPP.CREATEAPPOINTMENT ())
{
OAPTMT.SUBJECT = "Reminder";
OAPTMT.BODY = "Don't forget to exercise!"
OAPTMT.Start = datetime.now.addhours (1);
OAPTMT.BUSYSTATUS = busystatus.outofffice;
OAPTMT.SAVE ();
}
}
The effect is as follows:
Figure 4: Applying Pocket Outlook adding dating on SmartPhone
Figure 5: Applying Pocket Outlook adding dating on Pocket PC
This article comes from: my .NET life
http://blog.joycode.com/musicland/articles/34511.aspx