- When the form is resized, how to dynamically change the size of the control of many VB programmers headaches. Some people set Resizable form the size of the control but do not change; some people are under the control of absolute position and window size with addition and subtraction approach to re-position the control and change the size, this approach is relatively more complicated and can not be reused; Of course, some people are limited not to change the window altogether. Is there a simple way? The answer is yes, here are a permanent solution, source code is as follows:
Option Explicit
Private FormOldWidth As Long
`Save the form of the original width
Private FormOldHeight As Long
`Save the form of the original height
`In the call to call this function before 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
`Change in proportion to the size of each component within the form,
Call before the call ReSizeForm ReSizeInit function
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 form width scaling
ScaleY = FormName.ScaleHeight / FormOldHeight
Save the form `a high degree of scaling
On Error Resume Next
For Each Obj In FormName
StartPos = 1
For I = 0 To 4
`Read the original location and size of the control
TempPos = InStr (StartPos,
Obj.Tag, "", vbTextCompare)
If TempPos> 0 Then
Pos (I) = Mid (Obj.Tag,
StartPos, TempPos - StartPos)
StartPos = TempPos + 1
Else
Pos (I) = 0
End If
`According to the original location and form control to change the size of the
The proportion of the controls reposition and resize
Obj.Move Pos (0) backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news : 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only ScaleX, Pos (1)
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar. gz xml2dict-read-only ScaleY, Pos (2) backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only ScaleX, Pos (3) backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news : 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only ScaleY
Next I
Next Obj
On Error GoTo 0
End Sub
Private Sub Form_Load ()
Call ResizeInit (Me) `the procedure must be added into
End Sub
Private Sub Form_Resize ()
Call ResizeForm (Me) `to ensure that change control and changes the form
End Sub
---- In this case are given two functions: ResizeInit and ResizeForm, before calling ResizeForm must call ResizeInit. You can by copying the program code in the form, and then adding any controls on the form where you can test - when the form is resized, how to dynamically change the size of the control of many VB programmers headaches. Some people set Resizable form the size of the control but do not change; some people are under the control of absolute position and window size with addition and subtraction approach to re-position the control and change the size, this approach is relatively more complicated and can not be reused; Of course, some people are limited not to change the window altogether. Is there a simple way? The answer is yes, here are a permanent solution, source code is as follows:
Option Explicit
Private FormOldWidth As Long
`Save the form of the original width
Private FormOldHeight As Long
`Save the form of the original height
`In the call to call this function before 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
`Change in proportion to the size of each component within the form,
Call before the call ReSizeForm ReSizeInit function
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 form width scaling
ScaleY = FormName.ScaleHeight / FormOldHeight
Save the form `a high degree of scaling
On Error Resume Next
For Each Obj In FormName
StartPos = 1
For I = 0 To 4
`Read the original location and size of the control
TempPos = InStr (StartPos,
Obj.Tag, "", vbTextCompare)
If TempPos> 0 Then
Pos (I) = Mid (Obj.Tag,
StartPos, TempPos - StartPos)
StartPos = TempPos + 1
Else
Pos (I) = 0
End If
`According to the original location and form control to change the size of the
The ratio of the re-orientation and change the size of the control
Obj.Move Pos (0) backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news : 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only ScaleX, Pos (1)
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar. gz xml2dict-read-only ScaleY, Pos (2) backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only ScaleX, Pos (3) backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news : 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only ScaleY
Next I
Next Obj
On Error GoTo 0
End Sub
Private Sub Form_Load ()
Call ResizeInit (Me) `the procedure must be added into
End Sub
Private Sub Form_Resize ()
Call ResizeForm (Me) `to ensure that change control and changes the form
End Sub
---- In this case are given two functions: ResizeInit and ResizeForm, before calling ResizeForm must call ResizeInit. You can by copying the program code in the form, and then adding any controls on the form where you can test
Recommended links:
Hot Science Education
how to install INSTALL windows media player 11
Operation and further investment to maintain essential
Photoshop Production - wire and spark
DivX to VOB
Quality Control in the "Statistics" several concepts
Simple table space to talk about Visual Basic.NET transmission
JSP2.0 simple symbol library extension _SimpleTag
With CloneCD CD-RW disc to save the damaged
Followed By A Variety Of Patches Manually Clear The New "Annie"
TS To WMV
FLV to 3GP
Review Basic Or VB Or VB DotNet
Easy to use Terminal And Telnet Clients