1 如何通过HWND获得CWnd指针
// 获得当前窗口的句柄
HWND hWnd = GetSafeHwnd();
// 通过HWND获得CWnd指针
CWnd* pWnd = CWnd::FromHandle(hWnd);
CString strText = _T("");
strText.Format("pWnd=0x%X\nthis=0x%X\n", pWnd, this);
AfxMessageBox(strText);
2 如何获得应用程序主窗口的指针
// 获得应用程序指针
CDemoApp* pApp = (CDemoApp*)AfxGetApp();
// 获得主窗口指针
CWnd* pMainWnd = pApp->m_pMainWnd;
CString strText = _T("");
strText.Format("pMainWnd=0x%X\nthis=0x%X\n", pMainWnd, this);
AfxMessageBox(strText);
4 如何最大化、最小化窗口、恢复窗口