日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

mfc对话框的二次切分

發布時間:2025/5/22 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mfc对话框的二次切分 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在這里插入代碼片一:首先需要建兩個類,目的是到時候定義劃分的窗口種類
點擊項目:項目圖片再點擊類向導
鼠標移動至添加類,點擊添加mfc類, 類名命名為FrameList ,基類選 CListView, 類名命名為FrameEdit 基類選 CEditView。
隨后點擊類向導,添加消息函數WM_Create.再在消息函數中添加如下代碼

CCreateContext ctxList, ctxEdit; ctxList.m_pNewViewClass = RUNTIME_CLASS(FrameEdit); ctxList.m_pCurrentDoc = NULL; ctxList.m_pNewDocTemplate = NULL; ctxList.m_pLastView = NULL; ctxList.m_pCurrentFrame = NULL;ctxEdit.m_pNewViewClass = RUNTIME_CLASS(FrameEdit); ctxEdit.m_pCurrentDoc = NULL; ctxEdit.m_pNewDocTemplate = NULL; ctxEdit.m_pLastView = NULL; ctxEdit.m_pCurrentFrame = NULL;// 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_pFrameWnd = new CFrameWnd(); m_pFrameWnd->Create(strMyClass, _T(""), WS_CHILD, CRect(0, 0, 50, 50), this); m_pFrameWnd->ShowWindow(SW_SHOW); m_pFrameWnd->MoveWindow(0, 0, 500, 400);// and finally, create the splitter with the frame as // the parentm_wndSplitter.CreateStatic(m_pFrameWnd, 1, 2);//建立第一層構架 //m_wndSplitter.CreateStatic(this, 1, 2);//建立第一層構架 m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(FrameList), CSize(200,200), &ctxList); m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(FrameEdit), CSize(200, 200), &ctxEdit); m_wndSplitter2.CreateStatic(&m_wndSplitter, 3, 1, WS_CHILD | WS_VISIBLE | WS_BORDER,m_wndSplitter.IdFromRowCol(0,0));//建立第二層構架 m_wndSplitter.DeleteView(0,0);//動態拆分 m_wndSplitter2.CreateView(0, 0, RUNTIME_CLASS(FrameList), CSize(100, 100), &ctxList); m_wndSplitter2.CreateView(1, 0, RUNTIME_CLASS(FrameList), CSize(100,100), &ctxList); m_wndSplitter2.CreateView(2, 0, RUNTIME_CLASS(FrameList), CSize(100, 100), &ctxList); m_wndSplitter3.CreateStatic(&m_wndSplitter2, 1, 2, WS_CHILD | WS_VISIBLE | WS_BORDER,m_wndSplitter2.IdFromRowCol(0, 0)); m_wndSplitter3.CreateView(0, 0, RUNTIME_CLASS(FrameList), CSize(100, 100), &ctxList); return 0;

至此,主題部分寫完。隨后,我們需要在消息處理函數OnInitDialog中添加如下代碼

// TODO: 在此添加額外的初始化代碼 CRect rect; // 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. //GetDlgItem(IDD_THREECUT_DIALOG)->GetWindowRect(&rect);// Move the splitter ScreenToClient(&rect); m_pFrameWnd->MoveWindow(&rect); m_pFrameWnd->ShowWindow(SW_SHOW); //m_wndSplitter.MoveWindow(0, 0, rect.Width(), rect.Height()); //m_wndSplitter.ShowWindow(SW_SHOW); return TRUE; // 除非將焦點設置到控件,否則返回 TRUE

寫成這樣還是會報錯,因為很多變量沒有定義,我們需要在 XXXDlg.h頭文件中定義如下變量

public: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); CFrameWnd *m_pFrameWnd; CSplitterWnd m_wndSplitter; CSplitterWnd m_wndSplitter2;

到此,所有代碼全部寫完。運行時會有個中斷,我也沒有弄清原因,點忽略就會看到想要的結果。

總結

以上是生活随笔為你收集整理的mfc对话框的二次切分的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。