Public Class Form1
Private Const MOUSECLICK1 As UInteger = &H112
Private Const MAXBUTTON1 As UInteger = &HF030
'重载窗体的窗口函数WndProc截获两个消息
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If (m.Msg = MOUSECLICK1) Then
If (m.WParam = MAXBUTTON1) Then //最大化按钮消息
Me.Top = 0
Me.Height = Screen.PrimaryScreen.Bounds.Height - 50
Me.Refresh()
Return
End If
End If
MyBase.WndProc(m)
End Sub
End Class
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If (m.Msg = &H112) Then
If (m.WParam = &HF020) Then
Console.WriteLine( 最小化按钮点击了 )
ElseIf (m.WParam = &HF030) Then
Console.WriteLine( 最大化按钮点击了 )
ElseIf (m.WParam = &HF060) Then
Console.WriteLine( 关闭按钮点击了 )
End If
End If
MyBase.WndProc(m)
end sub