Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Sub ReleaseCapture Lib "User32" ()
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim lngReturnValue As Long
    If Button = 1 Then
        'Release capture
        Call ReleaseCapture
        'Send a 'left mouse button down on caption'-message to our form
        lngReturnValue = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    End If
End Sub
Private Sub Form_Paint()
    Me.Print "Click on the form, hold the mouse button and drag it"
End Sub

解决方案 »

  1.   

    是不是缺少dll动态连接之类的东东???????
      

  2.   

    98下的api可能和2000下的有点区别
    我以前在98下拖动好用的,但是拿到2000下也不好用了
      

  3.   

    Private Declare Function ReleaseCapture Lib "user32" () As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim r As Long
        If Button = 1 Then
            i = ReleaseCapture()
            r = SendMessage(hwnd, &HA1, 2, 0)
        End If
    End Sub
      

  4.   

    我想不会缺少dll动态连接
    ReleaseCapture,SendMessage声明如下:Public Declare Function SendMessage Lib "user32" Alias "SendMessageW" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
    Public Declare Function ReleaseCapture Lib "user32" () As Long
      

  5.   

    怎么没高手了吗?换一个说法,就是:在Win98下怎样实现用鼠标左键拖动没标题栏的窗体?