VC achieves any split of dialog box windows

Source: Internet
Author: User

 

   
VC implementation dialog box window arbitrary split


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 other dialog Resources
Here, you must select the idd_formview class dialog box to create cmyformview0 classes respectively.
And cmyformview1, select cdialog for the Base category, and 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 =
Afxregisterwndclass (cs_vredraw | cs_hredraw,

: Loadcursor (null, idc_arrow), (hbrush)
: Getstockobject (white_brush ),
: Loadicon (null,
Idi_application ));

// Create the frame window with "this" as
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 and two columns.

M_csplitter.createview (100,100, runtime_class (cmyformview0), csize ),
Null); // The first row and column
M_csplitter.createview (0, 1, runtime_class (cmyformview1 ),
Csize (100,100), null); // the second column of the First row

Return 0;
}

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;
}

From: http://hi.baidu.com/regdt32/blog/item/01a914ef4e0eee262cf53444.html

 

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.