在应用程序类中捕获同步消息。
前提条件
必须使用 Microsoft 基础类开发应用程序。
应用程序必须创建和注册自定义窗口类名才能发出通知。
打开应用程序类的 [Class Wizard]。
在 [Messages] 列表中,选中 [PreTranslateMessage],然后单击 [Add Function]。
单击 [Edit Code]。
PreTranslateMessage 方法出现。
将 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 方法。
![]() |
使用DocCommentXchange讨论此页。
|
版权 © 2013, SAP 股份公司或其关联公司. - SAP Sybase SQL Anywhere 16.0 |