主窗口指针保存在CWinThread::m_pMainWnd中,可以先调用AfxGetApp函数获得应用程序的指针,然后通过应用程序的指针获得其主窗口的指针。

	//获得应用程序指针
	CMy1_2App* pApp = (CMy1_2App*)AfxGetApp();
	//获得主窗口指针
	CWnd* pMainWnd = pApp->m_pMainWnd;
	CString strText = _T("");
	strText.Format("pMainWnd = 0x%x\nthis = 0x%x\n", pMainWnd, this);
	AfxMessageBox(strText);

 

相关文章:

  • 2022-12-23
  • 2021-08-26
  • 2021-11-25
  • 2022-12-23
  • 2021-11-04
  • 2021-12-29
  • 2022-12-23
  • 2021-12-27
猜你喜欢
  • 2021-11-15
  • 2021-11-04
  • 2021-12-22
  • 2022-03-07
  • 2021-09-29
  • 2022-01-15
  • 2022-12-23
相关资源
相似解决方案