一个基于对话框的程序,要实现:当按下某个按钮时,发送消息,而运行另外一个类的一个成员函数。可是当按下按钮时,为什么程序就没有反应啊?恳求大家帮忙,谢谢!谢谢!按下对话框的按钮运行的程序是:
void CClassMessThreadDlg::OnBUTTONTest() 
{
// TODO: Add your control notification handler code here
HWND   hDlg=(HWND)*this;
::PostMessage(hDlg,WM_StartTest,1,NULL);
}另外一个类的头文件是:
CaptureVideo.h
#define WM_StartTest WM_USER+1
//////////////////////////////////////////////////////////////////////////
class CCaptureVideo : public CWnd
{
// Construction
public:
CCaptureVideo();// Attributes
public:
// Operations
public:
void RunTest();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCaptureVideo)
protected:
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL// Implementation
public:
virtual ~CCaptureVideo(); // Generated message map functions
protected:
//{{AFX_MSG(CCaptureVideo)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};另外一个类对应的.CPP文件是:
CaptureVideo.cpp内容是:
...
BEGIN_MESSAGE_MAP(CCaptureVideo, CWnd)
//{{AFX_MSG_MAP(CCaptureVideo)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
ON_MESSAGE(WM_StartTest,RunTest)
END_MESSAGE_MAP()
...
void CCaptureVideo::RunTest()
{
AfxMessageBox("RunTest函数开始运行 !");
}