如何拦截.Net控制台应用程序中的WndProc事件

时间:2016-04-07 17:20:27

标签: .net console-application wndproc

我有一个单页Winforms应用程序的示例代码

我想在控制台应用程序中重用它

示例代码:

Protected Overrides Sub WndProc(ByRef msg As Message)
        If (msg.Msg = SGFPMMessages.DEV_AUTOONEVENT) Then
            If (msg.WParam.ToInt32() = SGFPMAutoOnEvent.FINGER_ON) Then
                StatusBar.Text = "Device Message: Finger On"
            ElseIf (msg.WParam.ToInt32() = SGFPMAutoOnEvent.FINGER_OFF) Then
                StatusBar.Text = "Device Message: Finger Off"
            End If
        End If

        MyBase.WndProc(msg)
End Sub

我的尝试:

Imports System.Windows.Forms

Sub WndProc(ByRef msg As Message)
        If (msg.Msg = SGFPMMessages.DEV_AUTOONEVENT) Then
            If (msg.WParam.ToInt32() = SGFPMAutoOnEvent.FINGER_ON) Then
                Console.Title = "Device Message: Finger On"
            ElseIf (msg.WParam.ToInt32() = SGFPMAutoOnEvent.FINGER_OFF) Then
                Console.Title = "Device Message: Finger Off"
            End If
        End If

        //MyBase.WndProc(msg)
End Sub

0 个答案:

没有答案