Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Public Class Form1
Private Const WM_SYSCOMMAND As Integer = 274
Private Const MF_STRING As Integer = 0
Private Const MF_SEPARATOR As Integer = 2048
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
Private Shared Function GetSystemMenu(ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr
End Function
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
Private Shared Function AppendMenu(ByVal hMenu As IntPtr, ByVal uFlags As Integer, ByVal uIDNewItem As Integer, ByVal lpNewItem As String) As Boolean
End Function
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
Private Shared Function InsertMenu(ByVal hMenu As IntPtr, ByVal uPosition As Integer, ByVal uFlags As Integer, ByVal uIDNewItem As Integer, ByVal lpNewItem As String) As Boolean
End Function
Private SYSMENU_ABOUT_ID As Integer = 1
Public Sub CustomForm()
End Sub
Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
MyBase.OnHandleCreated(e)
Dim hSysMenu As IntPtr = GetSystemMenu(Me.Handle, False)
AppendMenu(hSysMenu, MF_SEPARATOR, 0, String.Empty)
AppendMenu(hSysMenu, MF_STRING, SYSMENU_ABOUT_ID, "&About…")
End Sub
Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc(m)
If (m.Msg = WM_SYSCOMMAND) AndAlso (CInt(m.WParam) = SYSMENU_ABOUT_ID) Then
MessageBox.Show("Custom About Dialog")
End If
End Sub
End Class
fuente: https://stackoverflow.com/questions/4615940/how-can-i-customize-the-system-menu-of-a-windows-form
No hay comentarios.:
Publicar un comentario