WndProc: How to get window messages when form is minimized

前端 未结 3 1650
夕颜
夕颜 2021-01-02 22:01

To communicate with a certain service, I have to override the WindProc. and receive window messages.

However, when the form is minimized, I get no longe

3条回答
  •  礼貌的吻别
    2021-01-02 22:26

    You can try NativeWindow to receive messages (VB code, sorry):

    Imports System.Windows.Forms
    
    Public Class MyClass: Inherits NativeWindow
    
    Private piFormHandle As Integer = 0
    Sub New()
        Me.CreateHandle(New CreateParams)
        piFormHandle = CInt(Me.Handle)
    End Sub
    
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Select Case (m.Msg)
            Case MyMessage
        End Select
        MyBase.WndProc(m)
    End Sub
    
    End Class
    

提交回复
热议问题