Notification Window Messages

Send Feedback

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 you want. Possible flags 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 = Database OID.

Code Example

The following code example demonstrates how to use Notification Window Messages.

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 the 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. 
    //         (ie changes made in another process).
    hr = SubscribeToNotifications(pPoom, olFolderContacts, PIMFOLDERNOTIFICATION_REMOTE);

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

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

    return;

}

// Function to subscribe to notifications based on folder type.
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);

    pItem->Release();
    pFolder->Release();

    return hr;

}

Requirements

Pocket PC: Windows Mobile Version 5.0 and later
Smartphone: Windows Mobile Version 5.0 and later
OS Versions: Windows CE 5.01 and later
Header: pimstore.h
Library: pimstore.lib

See Also

Pocket Outlook Object Model API Notifications | IPOutlookApp::Logon

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.