在MFC中,m_pMainWnd是指向哪里的?运行过程中该指针起什么作用?
答案:1 悬赏:0
解决时间 2021-01-28 03:35
- 提问者网友:不要迷恋哥
- 2021-01-27 21:14
在MFC中,m_pMainWnd是指向哪里的?运行过程中该指针起什么作用?
最佳答案
- 二级知识专家网友:山君与见山
- 2021-01-27 22:04
BOOL CXxApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CXxDlg dlg;
m_pMainWnd = &dlg;
请看最后一行代码m_pMainWnd = &dlg;,也即是在向导生成代码的时候会根据向导设置,将m_pMainWnd指向主对话框(基于对话框的项目)或CMainFrame(基于文档/视图的项目)。
后期基本不会直接用到该指针(除非在App类里面),其他地方需要获取主窗口句柄时,一般使用AfxGetMainWnd函数。
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CXxDlg dlg;
m_pMainWnd = &dlg;
请看最后一行代码m_pMainWnd = &dlg;,也即是在向导生成代码的时候会根据向导设置,将m_pMainWnd指向主对话框(基于对话框的项目)或CMainFrame(基于文档/视图的项目)。
后期基本不会直接用到该指针(除非在App类里面),其他地方需要获取主窗口句柄时,一般使用AfxGetMainWnd函数。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯