VC完成對話框窗口隨意率性朋分。本站提示廣大學習愛好者:(VC完成對話框窗口隨意率性朋分)文章只能為提供參考,不一定能成為您想要的結果。以下是VC完成對話框窗口隨意率性朋分正文
小我以為簡略成績最好就是直接貼源代碼,一看就明確,說來講去反而弄不清晰,那我就少空話了,本身看吧,正文很清晰。
先來張圖片
1. 新建一個MFC對話框法式MySplitterDlg。 再拔出兩個Dialog資本 ,這裡必定要選擇IDD_FORMVIEW種別的對話框,分離新建類CMyFormView0 和CMyFormView1,基種別選CDialog,必定要選擇CFormView。
2. CMySplitterDlg中增長WM_CREATE的新聞呼應,編纂OnCreate()
int CMySplitterDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// Because the CFRameWnd needs a window class, we will create a new one. I just copied the sample from MSDN Help.
// When using it in your project, you may keep CS_VREDRAW and CS_HREDRAW and then throw the other three parameters.
//須要注冊窗口類
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_pMyFrame = new CFrameWnd;
m_pMyFrame->Create(strMyClass,"", WS_CHILD, CRect(0,0,300,300), this);
m_pMyFrame->ShowWindow(SW_SHOW);
// and finally, create the splitter with the frame as the parent
m_cSplitter.CreateStatic(m_pMyFrame,1, 2); //在Frame裡切分視圖窗口為1×2,就是一行兩列
m_cSplitter.CreateView(0,0, RUNTIME_CLASS(CMyFormView0), CSize(100,100), NULL);//第一行一列
m_cSplitter.CreateView(0,1, RUNTIME_CLASS(CMyFormView1), CSize(100,100), NULL);//第一行二列
return 0;
}
3. 在CMySplitterDlg::OnInitDialog()中顯示Frame
int CMySplitterDlg::OnInitDialog()
{
CDialog::OnInitDialog();
GetWindowRect(&cRect);
ScreenToClient(&cRect);
m_pMyFrame->MoveWindow(&cRect);
m_pMyFrame->ShowWindow(SW_SHOW);
return TRUE;
}