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