VC++ MFC 對話方塊 視窗分割
阿新 • • 發佈:2019-01-29
找了幾個教程都比較早了
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
- ::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)
- {
- 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);