Optimization of the MDI form-top

Source: Internet
Author: User

For the charging system of the data center that has just been claimed.

In this system, the outermost layer is an MDI form. Other operations are performed in the MDI subform.


When we see this form, we do not hesitate to say that the main form of this form is an MDI form. All others are their subforms.

Therefore, when creating a system, create an MDI form. However, we will find that buttons and other controls cannot be added to the MDI form. Therefore, we need a container control. Most people will think of picturebox because it is a very simple and representative container control.

There was nothing wrong with the main form. However, when you have an MDI subform form1, you will find the problem. No matter how you adjust it, The subform form1 cannot be seen.

 

The following is a small example to solve the above problems.

This is an MDI form. The above is a picturebox control. When you click the button, the form1 subform is displayed.


When you click the button, you will see the following situation.


The child forms form1 and picture are at the same level. Therefore, the child form is invisible.

Here is a solution:

Use the API function ---- to set form1 to a subform of picturebox. In this way, form1 can be displayed in front of picturebox.

Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As LongPrivate Sub Command1_Click()    SetParent Form1.hWnd, MDIForm1.hWnd    Form1.ShowEnd Sub

By using the API function, you can place the subform form1 on picturebox and display it.




However, if form1 is not completely displayed, you need to set the length and width of the child form.

Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As LongPrivate Sub Command1_Click()    SetParent Form1.hWnd, MDIForm1.hWnd    Form1.Show    Form1.Width = Picture1.ScaleWidth    Form1.Height = Picture1.ScaleHeightEnd Sub


Although the problem is solved, the appearance of the view is broken.

The title bar after the MDI sub-form is maximized is under the menu bar of the MDI form. In addition, after the MDI subform is minimized, it cannot be found.

 

For a more user-friendly main interface, we will explain it in the next section.


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.