事先声明,本人小白,hehe:单文本,在自定义的对话框类头文件中定义了消息#define WM_MYMESSAGE WM_USER+5类中定义了onok和cancel void listdlg::OnOK() 
{
// TODO: Add extra validation here
UpdateData();
CFrameWnd *pFrame = GetParentFrame();
pFrame->PostMessage (WM_MYMESSAGE,IDOK);
CDialog::OnOK();
}void listdlg::OnCancel() 
{
// TODO: Add extra cleanup here
CFrameWnd *pFrame = GetParentFrame();
pFrame->PostMessage (WM_MYMESSAGE,IDCANCEL);

CDialog::OnCancel();
}在frame中定义了这个消息的响应函数frame。cpp中
        BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_XUESHENG, OnXuesheng) //}}AFX_MSG_MAP
ON_MESSAGE(WM_MYMESSAGE,OnDialogMessage)
END_MESSAGE_MAP()frame。h中protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnXuesheng(); //}}AFX_MSG
afx_msg LRESULT OnDialogMessage(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
最后就是frame。cpp中的代码void CMainFrame::OnXuesheng() 
{
// TODO: Add your command handler code hereif (m_pdlg = NULL)
{ m_pdlg = new listdlg;
strName = "";
strNum = "";
strList = "" ;
strSex = "";
m_pdlg->Create(IDD_DIALOG1);
m_pdlg->ShowWindow (SW_SHOW);
}
else m_pdlg->SetActiveWindow(); 

}LRESULT OnDialogMessage(WPARAM wParam, LPARAM lParam)
{
switch(wParam)
{
case IDOK:
strName = m_pdlg->m_name ;
strNum = m_pdlg->m_num;
strList = m_pdlg->m_list ;
if(m_pdlg->m_sex == 0)  strSex = "男";
if(m_pdlg->m_sex == 1)  strSex = "女";
Invalidate();
break;
case IDCANCEL:
m_pdlg->DestoryWindow();
delete m_pdlg;
m_pdlg = NULL;
break;
}
return 0;
}然后就是错误一大堆,基本上OnDialogMessage里的东西全不认 ,对话框类的头文件也放在frame里了,变量也都定义过了,不知道为神马错,求教高手呀呀呀~MainFrm.cpp
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(144) : error C2065: 'strName' : undeclared identifier
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(144) : error C2065: 'm_pdlg' : undeclared identifier
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(144) : error C2227: left of '->m_name' must point to class/struct/union
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(145) : error C2065: 'strNum' : undeclared identifier
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(145) : error C2227: left of '->m_num' must point to class/struct/union
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(146) : error C2065: 'strList' : undeclared identifier
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(146) : error C2227: left of '->m_list' must point to class/struct/union
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(147) : error C2227: left of '->m_sex' must point to class/struct/union
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(147) : error C2065: 'strSex' : undeclared identifier
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(147) : error C2440: '=' : cannot convert from 'char [3]' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(148) : error C2227: left of '->m_sex' must point to class/struct/union
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(148) : error C2440: '=' : cannot convert from 'char [3]' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(149) : error C2065: 'Invalidate' : undeclared identifier
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(152) : error C2227: left of '->DestoryWindow' must point to class/struct/union
E:\Program Files\Microsoft Visual Studio\MyProjects\motai\MainFrm.cpp(153) : error C2541: delete : cannot delete objects that are not pointers
motai.cpp
e:\program files\microsoft visual studio\myprojects\motai\mainfrm.h(22) : error C2143: syntax error : missing ';' before '*'
e:\program files\microsoft visual studio\myprojects\motai\mainfrm.h(22) : error C2501: 'listdlg' : missing storage-class or type specifiers
e:\program files\microsoft visual studio\myprojects\motai\mainfrm.h(22) : error C2501: 'm_pdlg' : missing storage-class or type specifiers
motaiView.cpp
e:\program files\microsoft visual studio\myprojects\motai\mainfrm.h(22) : error C2143: syntax error : missing ';' before '*'
e:\program files\microsoft visual studio\myprojects\motai\mainfrm.h(22) : error C2501: 'listdlg' : missing storage-class or type specifiers
e:\program files\microsoft visual studio\myprojects\motai\mainfrm.h(22) : error C2501: 'm_pdlg' : missing storage-class or type specifiers