Static split window

Source: Internet
Author: User

Static split window

To create a static split window, follow these steps:

1. Define a csplitterwnd member object in the parent framework class.

2. Reload the cframewnd: oncreateclient member function of the parent framework class.

3. Call the createstatic member function of the csplitterwnd member object in the overloaded cframewnd: oncreateclient function, and then call the createview member function of the csplitterwnd member object to create a view for each pane.

Example: in the main frame window, create a static split window with two rows and one column in the customer area: (first create an MFC single document project named "example34)

1. In the mainfrm. h file, add the member object cmainframe class: csplitterwnd m_wndsplitter ;.

2. in the Class View, find the cmainframe class, right-click, and select Properties From the shortcut menu. The property page is displayed, and then click the "overrides" button on the toolbar of the property page, the list below lists the functions that can be reloaded. Find oncreateclient to generate the reload function.

3. Find the oncreateclient function that has just been overloaded in the mainfrm. cpp file and modify it. Because no other view classes are created, the top and bottom two pane views are cexample34view. To recognize the cexample34view class, add # include "example34view. H" to the mainfrm. cpp file and add # include "example34doc. H" to the example34view. h file ". The final oncreateclient function is modified as follows:

C ++ code
  1. Bool cmainframe: oncreateclient (lpcreatestruct lpcs, ccreatecontext * pcontext)
  2. {
  3. // Todo: add your specialized code here and/or call the base class
  4. Crect RC;
  5. // Obtain the crect object in the client area of the Framework Window.
  6. Getclientrect (& rc );
  7. // Create a static split window with two rows and one column
  8. If (! M_wndsplitter.createstatic (this, 2, 1 ))
  9. Return false;
  10. // Create a view in the preceding pane
  11. If (! M_wndsplitter.createview (0, 0, runtime_class (cexample34view), csize (RC. Width (), RC. Height ()/2), pcontext ))
  12. Return false;
  13. // Create a view in the following pane
  14. If (! M_wndsplitter.createview (1, 0, runtime_class (cexample34view), csize (RC. Width (), RC. Height ()/2), pcontext ))
  15. Return false;
  16. Return true;
  17. // Return cframewndex: oncreateclient (lpcs, pcontext );
  18. }

4. Run the program and turn off other panels on the result interface. The effect is as follows:

 

If you want to create a nested split window in a certain pane, You need to define a csplitterwnd object and use the csplitterwnd object in the parent pane as the parent frame window to create a split window.

How to associate a subwindow with a dialog box?

Class View, right-click the project name, class wizard, and select the MFC class from the add class drop-down menu ..., enter the class name cinfoview and select cformview as the base class. infoview is automatically generated. H and infoview. CPP and automatically generate a dialog box in mainfrm. the CPP file contains the header file infoview. h

Finally, modify the above Code:

  1. If (! M_wndsplitter.createview (0, 0, runtime_class (cinfoview), csize (RC. Width (), RC. Height ()/2), pcontext ))
  2. Return false;

In this way, the subwindow above is associated with the dialog box, that is, the subwindow above displays the dialog box.


Static split window

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.