Contents Index Adding ActiveSync synchronization (Windows API) TCP/IP, HTTP, or HTTPS synchronization from Windows CE pdf/preface.pdf

UltraLite User's Guide
  Developing Applications for Windows CE
    Synchronization on Windows CE
      Adding ActiveSync synchronization to your application

Adding ActiveSync synchronization (MFC)

If you are using Microsoft Foundation Classes to develop your application, you can catch the synchronization message in the main dialog class or in your application class. Both methods are described here.

Your application must create and register a custom window class name for notification. See Assigning class names for applications.

To add ActiveSync synchronization in the main dialog class

  1. Add a registered message and declare a message handler.

    Find the message map in the source file for your main dialog ( the name is of the same form as CMyAppDlg.cpp). Add a registered message using the static and declare a message handler using ON_REGISTERED_MESSAGE as in the following example:

    static UINT WM_ULTRALITE_SYNC_MESSAGE = 
       ::RegisterWindowMessage( UL_AS_SYNCHRONIZE );
    BEGIN_MESSAGE_MAP(CMyAppDlg, CDialog)
          //{{AFX_MSG_MAP(CMyAppDlg)
          //}}AFX_MSG_MAP
       ON_REGISTERED_MESSAGE( WM_ULTRALITE_SYNC_MESSAGE, 
          OnDoUltraLiteSync )
    END_MESSAGE_MAP()
  2. Implement the message handler.

    Add a method to the main dialog class with the following signature. This method is automatically executed any time the MobiLink provider for ActiveSync requests that your application synchronize. The method should call ULSynchronize.

    LRESULT CMyAppDlg::OnDoUltraLiteSync( 
       WPARAM wParam, 
       LPARAM lParam 
    );

    The return value of this function should be 0.

    For information on handling the synchronization message, see ULIsSynchronizeMessage function.

To add ActiveSync synchronization in the Application class

  1. Open up the Class Wizard for the application class.

  2. In the Messages list, highlight PreTranslateMessage and then click the Add Function button.

  3. Click the Edit Code button. The PreTranslateMessage function appears. Change it to read as follows:

    BOOL CMyApp::PreTranslateMessage(MSG* pMsg) 
    {
       if( ULIsSynchronizeMessage(pMsg->message) ) {
          DoSync();
          // close application if launched by provider
          if( pMsg->wParam == 1 ) {
             ASSERT( AfxGetMainWnd() != NULL );
             AfxGetMainWnd()->SendMessage( WM_CLOSE );
          }
          return TRUE;   // message has been processed
       }
       return CWinApp::PreTranslateMessage(pMsg);
    }

    where DoSync is the function that actually calls ULSynchronize.

    For information on handling the synchronization message, see ULIsSynchronizeMessage function.


Contents Index Adding ActiveSync synchronization (Windows API) TCP/IP, HTTP, or HTTPS synchronization from Windows CE pdf/preface.pdf