【发布时间】:2015-01-22 13:15:22
【问题描述】:
我正在尝试向我的 MFC 应用程序添加辅助窗口。这是我为显示主窗口而写的:
标题:
class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance ();
};
class CMainWindow : public CFrameWnd
{
public:
CMainWindow (char *p_mchar);
protected:
afx_msg void OnPaint ();
DECLARE_MESSAGE_MAP();
};
源文件:
#include <afxwin.h>
#include <afxmt.h>
#include "mfc0.h"
#include <string.h>
CMyApp myApp;
BOOL CMyApp::InitInstance ()
{
m_pMainWnd = new CMainWindow("Test 1");
m_pMainWnd->ShowWindow (m_nCmdShow);
m_pMainWnd->UpdateWindow ();
return TRUE;
}
BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
ON_WM_PAINT ()
END_MESSAGE_MAP ()
CMainWindow::CMainWindow (char *p_mchar)
{
Create (NULL, L"mfc0");
}
void CMainWindow::OnPaint ()
{
CPaintDC dc (this);
CMainWindow* hwnd = this;
}
我认为添加另一个 CFrameWnd 是可行的方法,但我不知道如何在应用程序中显示该窗口。我不能使用 m_pMainWnd 两次,对吧?必须有一个简单的解决方案,但我在这里有点迷失了。
【问题讨论】: