如何在view类静态函数中访问doc类成员变量?MFC
答案:2 悬赏:0 手机版
解决时间 2021-02-20 01:14
- 提问者网友:像風在裏
- 2021-02-19 05:37
如何在view类静态函数中访问doc类成员变量?MFC
最佳答案
- 五星知识达人网友:行雁书
- 2021-02-19 06:40
如果多文档或者单文档在你的对话框类里面包含view类和mainfrm类然后通过下面代码:
CMainFrame* pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
CYourView* g_pViw = (CYourView*)pFrame->GetActiveView();
g_pView->a就行了
若果是对话框程序:
通过AfxGetMainWnd()得到主机界面类指针。CMyDlg* pdlg=(CMyDlg*)AfxGetMainWnd();
pdlg->a就行了。
CMainFrame* pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
CYourView* g_pViw = (CYourView*)pFrame->GetActiveView();
g_pView->a就行了
若果是对话框程序:
通过AfxGetMainWnd()得到主机界面类指针。CMyDlg* pdlg=(CMyDlg*)AfxGetMainWnd();
pdlg->a就行了。
全部回答
- 1楼网友:舍身薄凉客
- 2021-02-19 07:20
如果多文档或者单文档在你的对话框类里面包含view类和mainfrm类然后通过下面代码:
CMainFrame* pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
CYourView* g_pViw = (CYourView*)pFrame->GetActiveView();
g_pView->a就行了
若果是对话框程序:
通过AfxGetMainWnd()得到主机界面类指针。CMyDlg* pdlg=(CMyDlg*)AfxGetMainWnd();
pdlg->a就行了。
CMainFrame* pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
CYourView* g_pViw = (CYourView*)pFrame->GetActiveView();
g_pView->a就行了
若果是对话框程序:
通过AfxGetMainWnd()得到主机界面类指针。CMyDlg* pdlg=(CMyDlg*)AfxGetMainWnd();
pdlg->a就行了。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯