以下是MSDN的例程,在VS2015下測驗,動態分割為什么不行?
// the following function is created by the MFC Application Wizard
// when you select Split window from the User Interface Features tab:
BOOL CMyChildFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
{
return m_wndSplitter.Create(this,
2, 2, // TODO: adjust the number of rows, columns
CSize(10, 10), // TODO: adjust the minimum pane size
pContext);
}
靜態分割可以實作,我就是像知道動態分割不行,問題出在哪里?多謝!
uj5u.com熱心網友回復:
http://blog.csdn.net/csdnmicrosoftcsdn/article/details/47952895uj5u.com熱心網友回復:
這文章我看過,動態分割,就是一句話,但是好像不行哦,你實驗過嗎?
uj5u.com熱心網友回復:
參考
// CDlgSplitDlg message handlers
#define DYN
BOOL CDlgSplitDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Because the CFrameWnd needs a window class
// Create the frame window with "this" as the parent
CRect rc;
GetDlgItem(IDC_CUTSOM_WINDOW)->GetWindowRect(&rc);
ScreenToClient(&rc);
int Wid=rc.Width()/2;
int Hei=rc.Height()/2;
//
m_pMyFrame = new CFrameWnd;
m_pMyFrame->Create("#32770"/* dialog */,"", WS_CHILD, rc, this);
// m_pMyFrame->MoveWindow(&rc);
// Initialize a context for the view.
CCreateContext cc;
cc.m_pNewViewClass = RUNTIME_CLASS(CMyView);
cc.m_pCurrentFrame = m_pMyFrame;
cc.m_pCurrentDoc = NULL;
cc.m_pNewDocTemplate = NULL;
cc.m_pLastView = NULL;
// Get the rectangle of the custom window. The custom window
// is just a a big button that is not visible and is disabled.
// It's a trick to not use coordinates directly.
// create the splitter with the frame as the parent
#ifdef _DEBUG
afxTraceEnabled=FALSE;
#endif
#ifdef DYN
m_Splitter.Create(m_pMyFrame, 2, 2, CSize(50,50), &cc, WS_CAPTION | WS_CHILD | WS_VISIBLE | SPLS_DYNAMIC_SPLIT);
// after created this is no use:
// m_Splitter.ModifyStyle(WS_HSCROLL | WS_VSCROLL,0);
m_Splitter.MoveWindow(0,0, rc.Width(), rc.Height());
m_Splitter.SplitRow(Hei);
m_Splitter.SplitColumn(Wid);
#else
m_Splitter.CreateStatic(m_pMyFrame, 2, 2);//
// create views
m_Splitter.CreateView(0,0, RUNTIME_CLASS(CMyView), CSize(Wid,Hei), &cc);
m_Splitter.CreateView(0,1, RUNTIME_CLASS(CMyView), CSize(Wid,Hei), &cc);
m_Splitter.CreateView(1,0, RUNTIME_CLASS(CMyView), CSize(Wid,Hei), &cc);
m_Splitter.CreateView(1,1, RUNTIME_CLASS(CMyView), CSize(Wid,Hei), &cc);
m_Splitter.MoveWindow(0,0, rc.Width(), rc.Height());
#endif
#ifdef _DEBUG
afxTraceEnabled=TRUE;
#endif
m_pMyFrame->ShowWindow(SW_SHOW);
m_Splitter.ShowWindow(SW_SHOW);
//
((CMyView*)m_Splitter.GetPane(0,0))->OnInitialUpdate();
((CMyView*)m_Splitter.GetPane(0,1))->OnInitialUpdate();
((CMyView*)m_Splitter.GetPane(1,0))->OnInitialUpdate();
((CMyView*)m_Splitter.GetPane(1,1))->OnInitialUpdate();
//
// SetTimer(1,10000,0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return
// FALSE
}
uj5u.com熱心網友回復:
參考MSDN檔案CCreateContext轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/78376.html
標籤:界面
