Controls in the form automatically change the size with the form

Source: Internet
Author: User
During development, developers often need to control the widget size to adapt to the window size, so that the software is proportional and coordinated under different resolutions.
So how can we make the controls in the form automatically change the size with the form?
I think there is an original method that is very useful, so that the form cannot be maximized: for example, the Apsara catering software .......
Of course, this method is a detour. The developed software will certainly not look good.
Well, let's introduce the following very useful Model. It's a professional Model.
--------------------------------------------------------------------------------
Option Explicit
Private FormOldWidth As Long
'Save the original width of the form.
Private FormOldHeight As Long
'Save the original height of the form.
'Call this function before calling ResizeForm
Public Sub ResizeInit (FormName As Form)
Dim Obj As Control
FormOldWidth = FormName. ScaleWidth
FormOldHeight = FormName. ScaleHeight
On Error Resume Next
For Each Obj In FormName
Obj. Tag = Obj. Left & "& Obj. Top &" & Obj. Width & "& Obj. Height &""
Next Obj
On Error GoTo 0
End Sub
'Proportionally change the size of each component in the form. Call the ReSizeInit function before calling ReSizeForm.
Public Sub ResizeForm (FormName As Form)
Dim Pos (4) As Double
Dim I As Long, TempPos As Long, StartPos As Long
Dim Obj As Control
Dim ScaleX As Double, ScaleY As Double

ScaleX = FormName. ScaleWidth/FormOldWidth
'Save the scaling ratio of the form width
ScaleY = FormName. ScaleHeight/FormOldHeight
'Save the zoom ratio of the form height
On Error Resume Next
For Each Obj In FormName
StartPos = 1

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.