解决方案 »

  1.   

    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
            oldProcAddr = SetWindowLongW(Panel1.Handle, GWL_WNDPROC, AddressOf callback)
        End Sub    Function callback(ByVal hWnd As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer        Select Case uMsg
                Case WM_LBUTTONDOWN
                    SendMessageW(Me.Handle, &HA1, 2, 0)
                Case Else
                    Return CallWindowProcW(oldProcAddr, hWnd, uMsg, wParam, lParam)
            End Select
            Return 0
        End Function
    End Class
    演示下SubClass