日期:2014-05-17  浏览次数:20805 次

caozhy进来帮下忙,谢谢
VB代码
Public Class Form1
    Declare Function SendMessageW Lib "user32" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
        MyBase.OnMouseDown(e)
        If e.Button = MouseButtons.Left Then
            Capture = False
            SendMessageW(Me.Handle, &HA1, 2, 0)
        End If
    End Sub
End Class

如果在窗体里有个Panel控件,我在Panel按下鼠标拖动,想窗体跟着移动,应该怎么搞。

------解决方案--------------------
http://www.pconline.com.cn/pcedu/empolder/net/0409/452601.html
------解决方案--------------------
Public Class Form1

    Declare Function SendMessageW Lib "user32" (ByVal hwnd As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

    Declare Function SetWindowLongW Lib "user32" (ByVal hWnd As Integer, ByVal ndx As Integer, ByVal newValue As callbacktype) As Integer

    Declare Function SetWindowLongW Lib "user32" (ByVal hWnd As Integer, ByVal ndx As Integer, ByVal newValue As Integer) As Integer

    Private Declare Function CallWindowProcW Lib "user32" (ByVal lpPrevWndFunc As Integer, ByVal hWnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

    Const GWL_WNDPROC As Integer = -4

    Const WM_LBUTTONDOWN As Integer = &H201

    Private oldProcAddr As Integer

    Delegate Function callbacktype(ByVal hWnd As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

    Private Sub Form1_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
        SetWindowLongW(Panel1.Handle, GWL_WNDPROC, oldProcAddr)
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load<