工程名为333
一个对话框DIALOG1对应的类为CAdd,另一个对话框DIALOG2对应的类为CTree
我想在CAdd里调用CTree里的函数。问怎么样才能调用.
CMy333App *pApp=(CMy333App *)AfxGetApp();
CTree *pTree=(CTree *)pApp->m_pMainWnd;
这样不好用,为什么
一个对话框DIALOG1对应的类为CAdd,另一个对话框DIALOG2对应的类为CTree
我想在CAdd里调用CTree里的函数。问怎么样才能调用.
CMy333App *pApp=(CMy333App *)AfxGetApp();
CTree *pTree=(CTree *)pApp->m_pMainWnd;
这样不好用,为什么
CTree *pTree=(CTree *)pApp->m_pMainWnd;
这样肯定不行的
你肯定要定义CAdd、CTree 变量吧?在那里定义的?
不说这个没法给你说的
建议你定义在 mainwnd里面
然后在各个类里面 (CMainFrame*)AfxGetApp()->m_pMainWnd->变量名
就OK了
void CAdd::OnButtonAdd()
{
// TODO: Add your control notification handler code here
CString sql;
UpdateData();
.........
验证完整性信息,且添加成功
.............
CMy333App *pApp=(CMy333App *)AfxGetApp();
CTree *pTree=(CTree *)pApp->m_pMainWnd;
pTree->ReadtoList("select * from student");
}
这么写不对呀。
CTree::OnButtonAdd()
{
CAddDig dlg;
if(dlg.DoModal()==IDADD)
{
//将CAdd的有关数据保存
}
}