我现在想做一个自定义功能的系统,在加载的时候,当鼠标放在左右边上的时候,显示拉动的图标,然后可以左右拉动大小,当鼠标放在这个控件中间的时候,这个控件可以拖动,如何才能实现?

解决方案 »

  1.   

    Private Const GWL_STYLE = (-16)
    Private Const WS_THICKFRAME = &H40000
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_NOZORDER = &H4
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_DRAWFRAME = &H20Private 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 LongPrivate Sub ControlSize(ControlName As Control, SetTrue As Boolean)
        Dim dwStyle As Long
        dwStyle = GetWindowLong(ControlName.hwnd, GWL_STYLE)
        If SetTrue Then
          dwStyle = dwStyle Or WS_THICKFRAME
        Else
          dwStyle = dwStyle - WS_THICKFRAME
        End If
        dwStyle = SetWindowLong(ControlName.hwnd, GWL_STYLE, dwStyle)
        SetWindowPos ControlName.hwnd, ControlName.Parent.hwnd, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
    End SubPrivate Sub Form_Load()
        ControlSize Picture1, True
        ControlSize Text1, True
    End Sub