vb6运行时想像设计时一样*调整控件大小位置解决办法

vb6运行时想像设计时一样*调整控件大小位置
如题,大家有好例子请提供下,谢谢
------解决方案--------------------
要达到VB窗体设计器那种效果(包括所有ActiveX控件)的缩放很麻烦,需要实现一大堆的接口,如果只想对窗口控件实现运行时缩放,可比较简单,具体代码如下:

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_THICKFRAME = &H40000
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const SWP_NOMOVE = &H2
Private Const SWP_FRAMECHANGED = &H20
Private Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long

Sub AllowSizeControl(allowSize As Boolean)
    Dim ctl As Control
    For Each ctl In Me.Controls
        If IsWindowControl(ctl) Then
            If allowSize Then
                SetWindowLong ctl.hwnd, GWL_STYLE, GetWindowLong(ctl.hwnd, GWL_STYLE) Or WS_THICKFRAME
            Else
                SetWindowLong ctl.hwnd, GWL_STYLE, GetWindowLong(ctl.hwnd, GWL_STYLE) And Not WS_THICKFRAME
            End If
            SetWindowPos ctl.hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_FRAMECHANGED
        End If
    Next
End Sub

Function IsWindowControl(ctl As Control) As Boolean
    Dim hwndCtrl As Long
    
    On Error Resume Next
    hwndCtrl = ctl.hwnd
    If Err.Number <> 0 Then
        Err.Clear
        IsWindowControl = False
    Else
        IsWindowControl = IsWindow(hwndCtrl)
    End If
End Function

Private Sub Command1_Click()
    AllowSizeControl True '允许调整控件大小
End Sub

Private Sub Command2_Click()
    AllowSizeControl False '禁止调整控件大小
End Sub

------解决方案--------------------