要如何修改picturebox控件类对象的属性,才能在运行时,用鼠标调整picturebox控件类对象的大小?

解决方案 »

  1.   

    Option Explicit
    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 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
    Const GWL_STYLE = (-16)
    Const WS_THICKFRAME = &H40000
    Const SWP_NOSIZE = &H1
    Const SWP_NOMOVE = &H2
    Const SWP_NOZORDER = &H4
    Const SWP_FRAMECHANGED = &H20        ’  The frame changed: send WM_NCCALCSIZE
    Const SWP_DRAWFRAME = SWP_FRAMECHANGEDPrivate Sub Form_Load()
        SetWindowLong Picture1.hwnd, GWL_STYLE, _
        GetWindowLong(Picture1.hwnd, GWL_STYLE) Or WS_THICKFRAME
        SetWindowPos Picture1.hwnd, hwnd, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
    End Sub
      

  2.   

    '好象可以直接就这样改吧?Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Picture1.Width - X <= 100 Then
        Picture1.MousePointer = 9
        If Button = 1 Then
            Picture1.Width = X
        End If
    Else
        Picture1.MousePointer = 0
    End If
    End Sub