我在OnCreate消息的CMainFrame中创建了一个CDockablePane窗口,如下所示:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
return -1;
//.........................some other code here
BOOL bNameValid;
CString strLoginPageWnd;
bNameValid = strLoginPageWnd.LoadString(IDS_LOGINPAGE_WND);
ASSERT(bNameValid);
if (!m_wndLoginPage.Create(strLoginPageWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_LOGINPAGEWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | CBRS_TOP | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create LoginPage window\n");
return -1; // failed to create
}
m_wndLoginPage.EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndLoginPage);
//..............................Some other code here
return 0;
}
m_wndLoginPage是CDockablePane窗口类对象的一个obejct。所以它工作正常并正确显示窗口如下:
所以我想要的是点击Login按钮后,显示另一个类似LoginWindow的CDockablePane窗口,Name应该出现在ToolBars和Docking Windows中,就像Login窗口一样。我试图添加下面的代码onLogin事件处理程序,但它不起作用:
BOOL bNameValid;
CString strLoginPageWnd2;
bNameValid = strLoginPageWnd2.LoadString(IDS_LOGINPAGE_WND2);
ASSERT(bNameValid);
CMainFrame *pMainWnd = (CMainFrame *)AfxGetMainWnd();
if (!m_wndLoginPage2.Create(strLoginPageWnd2, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_LOGINPAGEWND2, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | CBRS_TOP | CBRS_FLOAT_MULTI))
{
TRACE0("Failed to create LoginPage window\n");
return -1; // failed to create
}
m_wndLoginPage2.EnableDocking(CBRS_ALIGN_ANY);
pMainWnd->DockPane(&m_wndLoginPage2);
有人可以帮我解决如何创建另一个CDockablePane窗口并将其附加到CMainFrame的问题吗?