自己寫的OnCreateClient函式,本來是想分成3個視窗,可運行后沒變化。代碼和運行結果如下。
不知道為什么出錯,希望大佬們能幫忙解答一下。

uj5u.com熱心網友回復:
BOOL CDlgSplitDlg::OnInitDialog(){
//
m_pMyFrame = new CFrameWnd;
// or "#32770"/* dialog */
m_pMyFrame->Create(AfxRegisterWndClass(0),"", WS_CHILD, rc, this);
// 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_CHILD | WS_VISIBLE | SPLS_DYNAMIC_SPLIT);
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
}
所以要有:
1 m_pMyFrame = new CFrameWnd;
2 class CMySplitterWnd : public CSplitterWnd
3 class CMyView : public CEditView
uj5u.com熱心網友回復:
https://download.csdn.net/download/schlafenhamster/6233893"分割對話框.zip"
uj5u.com熱心網友回復:
CDialog 不會呼叫 OnCreateClient, 放到OnInitDialog 中處理轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/20122.html
標籤:基礎類
下一篇:OnCreateClient
