常见问题:自动调整窗口内控间的大小

2008-04-11 16:36:03来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

这是一个类模块:
1. 建立一个新的类模块,加入下列代码,并给类模块起名(例:autosize)
2. 加入一个窗口并且加入:Private el as new autosize
3. 在 Form_Load 事件中加入 el.init me
4. 在 Form_Resize 事件中加入 el.formresize me


Option Explicit
Private nFormHeight      As Integer
Private nFormWidth       As Integer
Private nNumOfControls   As Integer
Private nTop()           As Integer
Private nLeft()          As Integer
Private nHeight()        As Integer
Private nWidth()         As Integer
Private nFontSize()      As Integer
Private nRightMargin()   As Integer
Private bFirstTime       As Boolean

Sub Init(frm As Form, Optional nWindState As Variant)
   Dim I          As Integer
   Dim bWinMax    As Boolean

   bWinMax = Not IsMissing(nWindState)

   nFormHeight = frm.Height
   nFormWidth = frm.Width
   nNumOfControls = frm.Controls.Count - 1
   bFirstTime = True
   ReDim nTop(nNumOfControls)
   ReDim nLeft(nNumOfControls)
   ReDim nHeight(nNumOfControls)
   ReDim nWidth(nNumOfControls)
   ReDim nFontSize(nNumOfControls)

   ReDim nRightMargin(nNumOfControls)
   On Error Resume Next
   For I = 0 To nNumOfControls
      If TypeOf frm.Controls(I) Is Line Then
         nTop(I) = frm.Controls(I).Y1
         nLeft(I) = frm.Controls(I).X1
         nHeight(I) = frm.Controls(I).Y2
         nWidth
			   
			   

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:.net入门之VB篇:Visual Basic.Net中的文件操作(一)

下一篇:用VB编写一个弹出菜单类