C ++ VC implements any split of dialog box windows, vc windows

Source: Internet
Author: User

C ++ VC implements any split of dialog box windows, vc windows

I recently wrote an MFC program and want to implement any split of windows in the dialog box. It is troublesome to find something to copy the network information. At last, it was very simple and it was done very quickly. Write down and take a note.
I personally think that the best thing to do is to directly paste the source code. I will understand it at a glance, but I will not be clear at the end of the discussion. Then I will not talk nonsense about it. Let's take a look at it and make the comments quite clear.

First image

1. Create an MFC Dialog Box program MySplitterDlg. Insert two Dialog resources. Here, you must select the IDD_FORMVIEW class Dialog box to create the CMyFormView0 class and CMyFormView1 class respectively, and select CDialog for the Base category. You must select CFormView.

2. Add the message response WM_CREATE in CMySplitterDlg and edit OnCreate ()

Int CMySplitterDlg: OnCreate (maid) {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. // you need to register the window class CString strMyClass = callback (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 ); // split the View window in the Frame to 1 × 2, which is a row of m_cSplitter.CreateView (100,100, RUNTIME_CLASS (CMyFormView0), CSize (), NULL ); // m_cSplitter.CreateView (100,100, RUNTIME_CLASS (CMyFormView1), CSize (), NULL) in the first row; // return 0 in the second column of the First row ;}

3. display Frame in CMySplitterDlg: OnInitDialog ()

int CMySplitterDlg::OnInitDialog(){CDialog::OnInitDialog();GetWindowRect(&cRect);ScreenToClient(&cRect);m_pMyFrame->MoveWindow(&cRect);m_pMyFrame->ShowWindow(SW_SHOW);return TRUE;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.