Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 (中文) » UltraLite - C 和 C++ 编程 » 应用程序开发 » Windows Mobile 的 UltraLite 应用程序开发 » Windows Mobile 同步

 

在应用程序类中添加 ActiveSync 同步

在应用程序类中捕获同步消息。

前提条件

必须使用 Microsoft 基础类开发应用程序。

应用程序必须创建和注册自定义窗口类名才能发出通知。

 任务
  1. 打开应用程序类的 [Class Wizard]。

  2. 在 [Messages] 列表中,选中 [PreTranslateMessage],然后单击 [Add Function]。

  3. 单击 [Edit Code]。

    PreTranslateMessage 方法出现。

  4. 将 PreTranslateMessage 方法更改为如下内容:



    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);
    }

    DoSync 方法在此调用 ULSynchronize 方法。

结果

PreTranslateMessage 方法执行同步。

 另请参见