Compartilhar via


Notification Window Messages

4/8/2010

These messages are sent to the window handle (HWND) passed to the IPOutlookApp::Logon method. They are similar to the DB_CEOID_ messages from CEDB. The messages are sent only for databases (e.g., Appointments, Contacts, and Tasks) that you have subscribed to. Notifications are sent for both changes made by Outlook Mobile (the caller) via the _LOCAL messages, and for changes made by other processes via the _REMOTE messages.

You must subscribe for notifications by setting the PIMPR_FOLDERNOTIFICATIONS property on the folder you want, with the flags that you want. Possible flag values are PIMFOLDERNOTIFICATION_LOCAL and PIMFOLDERNOTIFICATION_REMOTE. The flags are independent, and you can set the value to 0 to stop notifications. For multiple folders of the same type, the last setting to this property from any of those folders, will be used for all such folders.

The following table lists the flags for receiving notifications.

Notification Value Description

PIMFOLDERNOTIFICATION_LOCAL

0x01

Notification for changes from this process.

PIMFOLDERNOTIFICATION_REMOTE

0x02

Notification for changes from other processes.

PIMFOLDERNOTIFICATION_ALL

0x03

Notification for changes from all processes. (PIMFOLDERNOTIFICATION_REMOTE | PIMFOLDERNOTIFICATION_LOCAL)

The following table lists the notification window messages for changes in local and remote processes.

Notification Value Description

PIM_ITEM_CREATED_LOCAL

WM_APP + 0x100

PIM item created locally.

PIM_ITEM_DELETED_LOCAL

WM_APP + 0x101

PIM item deleted locally.

PIM_ITEM_CHANGED_LOCAL

WM_APP + 0x102

PIM item changed locally.

PIM_ITEM_CREATED_REMOTE

WM_APP + 0x105

PIM item created remotely.

PIM_ITEM_DELETED_REMOTE

WM_APP + 0x106

PIM item deleted remotely.

PIM_ITEM_CHANGED_REMOTE

WM_APP + 0x107

PIM item changed remotely.

Note

wParam = Item OID, lParam = The folder containing the item.

Code Example 1

The following code example demonstrates how to subscribe to the different types of notifications.

Note

To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.

void NotificationsExample()
{
    HRESULT        hr    = E_FAIL;
    IPOutlookApp2 *pPoom = NULL;

    // Initialize COM for using the Pocket Outlook Object Model (POOM).
    CoInitializeEx(NULL, 0);

    // Get a reference to the POOM (Outlook Mobile) application object.
    hr = CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER, IID_IPOutlookApp2, (LPVOID*)&pPoom);
    
    // Logon to a POOM session. Pass-in a valid handle to the POOM session parent window so the notifications can be processed from it's wndproc. Outlook Mobile uses this handle for each PIM item's Display call, as well as for the infrared transfer dialog.

    hr = pPoom->Logon((long)hWnd);

    // CASE 1: Subscribe to local and remote appointment notifications.
    hr = SubscribeToNotifications(pPoom, olFolderCalendar, PIMFOLDERNOTIFICATION_ALL);

    // CASE 2: Subscribe to remote contact notifications. I.e., changes made in another IPOutlookApp instance.
    hr = SubscribeToNotifications(pPoom, olFolderContacts, PIMFOLDERNOTIFICATION_REMOTE);

    // CASE 3: Substribe for local task notifications. I.e., changes made in this IPOutlookApp instance.
    hr = SubscribeToNotifications(pPoom, olFolderTasks, PIMFOLDERNOTIFICATION_LOCAL);

    // Insert your code for creating a dialog window, here.

    return;
}

Code Example 2

The following code example demonstrates how to subscribe to notifications based on folder type.

Note

To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.

HRESULT SubscribeToNotifications(IPOutlookApp2 *pPoom, OlDefaultFolders olFolder, uint uiNotificationsType)
{
    HRESULT   hr       = 0;
    IFolder   *pFolder = NULL;
    IItem     *pItem   = NULL;
    CEPROPVAL propval  = {0};
    
    // Get the folder for the item type.
    hr = pPoom->GetDefaultFolder(olFolder, &pFolder);

    // Get the IItem interface for the IFolder.
    hr = pFolder->QueryInterface(IID_IItem, (LPVOID*)&pItem);

    // Set the folder's properties.
    propval.propid      = PIMPR_FOLDERNOTIFICATIONS;
    propval.val.ulVal   = uiNotificationsType;
    hr     = pItem->SetProps(0, 1, &propval);

    // Release resources.
    pItem->Release();
    pFolder->Release();

    return hr;
}

Remarks

To receive notifications, IPOutlookApp::Logon must be called from your application's main UI thread.

If IPOutlookApp::Logon is called from a secondary thread, that thread must implement a message dispatch loop.

Requirements

Header pimstore.h
Library Pimstore.lib
Windows Mobile Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later

See Also

Reference

Pocket Outlook Object Model Notifications
IPOutlookApp::Logon
Notification Flags

Other Resources