VC自定义消息

在stdAfx.h中添加

 

#define WM_MY_MESSAGE (WM_USER+100)

 

 

在dlg.cpp中添加

 

UINT CTestMessageDlg::OnMyMessage(WPARAM wParam, LPARAM lParam)
{
    
// TODO: 处理用户自定义消息...
    CString *dd = (CString*)lParam;
    AfxMessageBox(
*dd);

    
return 0;
}

 

 

 

ON_MESSAGE(WM_MY_MESSAGE, OnMyMessage)

 

 

dlg.h添加

 

afx_msg UINT OnMyMessage(WPARAM wParam, LPARAM lParam);

 

测试

 

代码
void CTest2::OnButton1() 
{
    
// TODO: Add your control notification handler code here
    CString dd = "Hello World2";
    ::SendMessage(((CTestMessageApp 
*)AfxGetApp())->m_pMainWnd->m_hWnd,
        WM_MY_MESSAGE, (WPARAM)(HWND)NULL, (LPARAM)
&dd);
}

 

https://files.cnblogs.com/kenter/101%e8%a7%84%e7%ba%a6%e6%8a%a5%e6%96%87%e5%88%86%e6%9e%90.zip

 

https://files.cnblogs.com/kenter/IEC101%e6%8a%a5%e6%96%87%e6%b5%81%e7%a8%8b.zip

 

 

posted @ 2010-12-21 20:53  kenter  阅读(178)  评论(0编辑  收藏  举报