Add About to the system menu

zhaozj2021-02-16  52

I want to implement this in VB.NET is also very simple, but the WndProc process that needs the overload window can handle the WM_SYSCOMMAND message.

Specific code: Private Declare Function GetSystemMenu Lib "user32" Alias ​​"GetSystemMenu" (ByVal hwnd As Int32, ByVal bRevert As Int32) As Int32 Private Declare Function InsertMenu Lib "user32" Alias ​​"InsertMenuA" (ByVal hMenu As Int32, ByVal nPosition As Int32 , ByVal wFlags As Int32, ByVal wIDNewItem As Int32, ByVal lpNewItem As String) As Int32 Private Const MF_BYCOMMAND = & H0 & Private Const MF_BYPOSITION = & H400 & Private Const MF_STRING = & H0 & Private Const MF_SEPARATOR = & H800 & Private Sub Form1_Load (ByVal sender As Object, ByVal e As System.eventargs) Handles mybase.load insertmenu (Me.Handle.Toint32, false), 6, mf_byposition or mf_string, 8888, "About me ... :)") InsertMenu (GetSystemMenu (Me.Handle.Toint32, False ), 7, MF_BYPOSITION OR MF_SEPARATOR, 8889, "") End Sub

Private Const WM_SYSCOMMAND As Integer = 274 Protected Overrides Sub WndProc (ByRef m As System.Windows.Forms.Message) If m.Msg = WM_SYSCOMMAND And m.WParam.ToInt32 = 8888 Then MsgBox (System.Environment.MachineName) End If MyBase. WndProc (m) end sub

转载请注明原文地址:https://www.9cbs.com/read-27506.html

New Post(0)