VC++ MFC 对话框 窗口分割
找了几个教程都比较早了
1).插入三个IDD_FORMVIEW
2)添加类:FormView1, FormView2,FormView3 基类:CFormView
3).在Dlg.h中添加
3.1
#include "FormView1"
#include "FormView2"
#include "FormView3”
3.2在Dlg.h中添加
- public:
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- public:
- CFrameWnd *m_pMyWnd;
- CSplitterWnd m_SplitterWnd;
- CSplitterWnd m_SplitterWnd2;
3.3在DLg.cpp中定义Oncreate
- int CSplitDlgDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CDialog::OnCreate(lpCreateStruct) == -1)
- return -1;
- CString strMyClass = AfxRegisterWndClass(CS_VREDRAW |CS_HREDRAW,
- ::LoadCursor(NULL, IDC_ARROW),
- (HBRUSH) ::GetStockObject(WHITE_BRUSH),
- ::LoadIcon(NULL, IDI_APPLICATION));
- // Create the frame window with "this" as the parent
- m_pMyWnd = new CFrameWnd;
- m_pMyWnd->Create(strMyClass,_T(""), WS_CHILD,
- CRect(0,0,200,200), this);
- m_pMyWnd->ShowWindow(SW_SHOW);
- if (m_SplitterWnd.CreateStatic(m_pMyWnd,1, 2) == NULL) //1行2列
- {
- return -1;
- }
- if(m_SplitterWnd2.CreateStatic(&m_SplitterWnd,2,1,WS_CHILD|WS_VISIBLE,m_SplitterWnd.IdFromRowCol(0,1)) == NULL)
- {
- return -1;
- }
- m_SplitterWnd.CreateView(0,0, RUNTIME_CLASS(CMyFormViewOne),
- CSize(100,100), NULL);
- m_SplitterWnd2.CreateView(0,0, RUNTIME_CLASS(CMyFormViewTwo),
- CSize(80,80), NULL);
- m_SplitterWnd2.CreateView(1,0, RUNTIME_CLASS(CMyFormViewThree),
- CSize(80,80), NULL);
- return 0;
- }
3.4在Dlg.cpp中OnInitDialog()添加
- CRect rect;
- GetWindowRect(&rect);
- ScreenToClient(&rect);
- m_pMyWnd->MoveWindow(&rect);
- m_pMyWnd->ShowWindow(SW_SHOW);