VC實現(xiàn)對話框窗口任意分割
個人認為簡單問題最好就是直接貼源代碼,一看就明白,說來說去反而弄不清楚,那我就少廢話了,自己看吧,注釋很清楚。
先來張圖片

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;
}
相關文章
VC++文件監(jiān)控之FindFirstChangeNotification
因為ReadDirectoryChangesW 上次測試發(fā)現(xiàn)不能多級目錄監(jiān)控,所以嘗試用FindFirstChangeNotification來實施文件監(jiān)控,需要的朋友可以參考下2019-04-04
C語言數(shù)據(jù)結構之學生信息管理系統(tǒng)課程設計
這篇文章主要為大家詳細介紹了C語言數(shù)據(jù)結構之學生信息管理系統(tǒng)課程設計,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-11-11
C語言實現(xiàn)輸入一顆二元查找樹并將該樹轉換為它的鏡像
這篇文章主要介紹了C語言實現(xiàn)輸入一顆二元查找樹并將該樹轉換為它的鏡像,是數(shù)據(jù)結構中二元查找樹的一個比較經(jīng)典的算法,有不錯的借鑒價值,需要的朋友可以參考下2014-09-09

