[英]Adding CDialog inside CDockablePane and application becomes unresponsive
[英]Adding two dialogs(CDialog) to a dockablepane(CDockablePane) using CSplitterWndEx
在MFC應用程序中,存在一個可停靠窗格,該窗格使用CSplitterWndEx分為兩行。 我正在嘗試使用此拆分器添加兩個對話框:
BOOL CPaneSplitter::AddWindow(int row, int col, CWnd* pWnd , CString clsName ,
DWORD dwStyle,DWORD dwStyleEx, SIZE sizeInit)
{
// set the initial size for that pane
m_pColInfo[col].nIdealSize = sizeInit.cx;
m_pRowInfo[row].nIdealSize = sizeInit.cy;
ASSERT(pWnd->m_hWnd == NULL); // not yet created
// Create with the right size (wrong position)
CRect rect(CPoint(0,0), sizeInit);
if (!pWnd->CreateEx(dwStyleEx,clsName,NULL,dwStyle,rect,this,IdFromRowCol(row, col)))
{
return FALSE;
}
}
編輯:
這是創建拆分器的代碼:
int CSplitePane::OnCreate(LPCREATESTRUCT lp)
{
if(CDockablePane::OnCreate(lp)==-1)
return -1;
m_wndSplitter.CreateStatic(this,2,1);
DWORD dwStyle = WS_CHILD | WS_VISIBLE ;
if(!m_wndSplitter.AddWindow(0,0,&m_ChildDlg1,_T("My_Dailog_Pane"),dwStyle,0,CSize(100,100)))
return -1;
m_ChildDlg1.ShowWindow(SW_SHOWDEFAULT);
dwStyle = WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_SHAREIMAGELISTS;
if(!m_wndSplitter.AddWindow(1,0,&m_wndList,WC_LISTVIEW,dwStyle,0,CSize(100,100)))
return -1;
m_wndList.ModifyStyle(LVS_TYPEMASK, LVS_ICON);
return 0 ;
}
void CSplitePane::OnSize(UINT nType,int cx,int cy)
{
CDockablePane::OnSize(nType,cx,cy);
int cyTlb =0;// m_wndToolbar.CalcFixedLayout(FALSE, TRUE).cy;
CRect rect;
GetClientRect(rect);
m_ChildDlg1.SetWindowPos(NULL,rect.left, rect.top, rect.Width(),rect.Height(),SWP_NOACTIVATE|SWP_NOZORDER);
m_wndSplitter.SetWindowPos(NULL,rect.left
, rect.top + cyTlb
, rect.Width() , rect.Height() - cyTlb , SWP_NOZORDER | SWP_NOACTIVATE);
}
此方法接受CWnd作為參數,但我自己傳遞對話框,因此在運行應用程序時,窗格是分開的,但對話框控件不存在。
所以我的問題是:是否可以使用CSplitterWndEx將CDialog對象添加到窗格中?
如何使用CFormView派生類?
也許您正在尋找的是CPaneDialog
。 從VS 2008 Feature Pack Samples中查看SetPaneSize示例。 樣本摘錄:
void CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
if (!m_wndDlgBar.Create (_T("DialogBar"), this, TRUE,
MAKEINTRESOURCE (IDD_DLG_BAR),
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI,
ID_VIEW_DLGBAR))
{
TRACE0("Failed to create Dialog Bar\n");
return FALSE; // fail to create
}
m_wndDlgBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndDlgBar.DockToWindow (&m_wndWorkSpace, CBRS_ALIGN_BOTTOM);
...
}
void CMainFrame::OnViewDialogBar()
{
ShowPane (&m_wndDlgBar, !(m_wndDlgBar.IsVisible ()), FALSE, TRUE);
RecalcLayout ();
}
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.