1 // 自定义消息
 2 #define        MY_THREAD_MSG        WM_USER+1000
 3 
 4 ////////////////////////////////////////////////////////////////////////////
 5 //
 6 // PreTranslateMessage()如果要响应【自定义消息】必须用::PostMessage()发送自定义消息 
7
// PreTranslateMessage()不响应::SendMessage()发送的【自定义消息】 10 BOOL CMyThreadDlg::PreTranslateMessage(MSG* pMsg) 11 { 12 switch(pMsg->message) 13 { 14 case MY_THREAD_MSG: 15 AfxMessageBox(_T("测试线程消息")); 16 break; 17 case WM_KEYDOWN: 18 if (VK_RETURN == pMsg->wParam || VK_ESCAPE == pMsg->wParam) 19 { 20 return TRUE; 21 } 22 break; 23 } 24 25 return CDialogEx::PreTranslateMessage(pMsg); 26 } 27 28 void CMyThreadDlg::OnBnClickedButton1() 29 { 30 // 发送自定义消息 31 ::PostMessage(AfxGetMainWnd()->m_hWnd, MY_THREAD_MSG, 0, 0); 32 }

 

相关文章:

  • 2021-08-08
  • 2022-12-23
  • 2021-08-13
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
猜你喜欢
  • 2022-12-23
  • 2021-10-27
  • 2021-07-18
  • 2022-12-23
相关资源
相似解决方案