Joe,
You need to use the GetSystemMenu API, AppendMenu & DeleteMenu then handle
the events in the WndProc sub.
I write this example in 2002 & should change the function declarations to
the DllImport...
This just leaves minimise & close on the system menu:
Declations:
Private Declare Function GetSystemMenu Lib "user32" Alias
"GetSystemMenu" _
(ByVal hwnd As Integer, ByVal bRevert As Integer) As Integer
Private Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" _
(ByVal hMenu As Integer, ByVal wFlags As Integer, _
ByVal wIDNewItem As Integer, ByVal lpNewItem As String) As Integer
Private Declare Function DeleteMenu Lib "user32" Alias "DeleteMenu" _
(ByVal hMenu As Integer, ByVal nPosition As Integer, _
ByVal wFlags As Integer) As Integer
Private Const MF_BYPOSITION As Integer = &H400&
Private Const MF_SEPARATOR As Integer = &H800&
Private Const MF_STRING As Integer = &H0&
Private Const WM_SYSCOMMAND As Integer = &H112
Form Load:
' Get the system menu
Dim iMenu As Integer = GetSystemMenu(Me.Handle.ToInt32, 0)
' Delete all system menu item except minimize
DeleteMenu(iMenu, 6, MF_BYPOSITION)
DeleteMenu(iMenu, 5, MF_BYPOSITION)
DeleteMenu(iMenu, 4, MF_BYPOSITION)
DeleteMenu(iMenu, 2, MF_BYPOSITION)
DeleteMenu(iMenu, 1, MF_BYPOSITION)
DeleteMenu(iMenu, 0, MF_BYPOSITION)
' Add a seperator
AppendMenu(iMenu, MF_SEPARATOR, 1000, "")
' Add the 'close' menu item
AppendMenu(iMenu, MF_STRING, 1001, "Close")
WndProc:
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_SYSCOMMAND Then
Select Case m.WParam.ToInt32
Case 1001
' User clicked close - show a copyright message
MessageBox.Show("This application is © 2007 Newbie
Coder. All Rights Reserved", _
Me.Text, MessageBoxButtons.OK,
MessageBoxIcon.Information)
' Exit the application
Application.Exit()
End Select
End If
MyBase.WndProc(m)
End Sub
Remember you use the Append or Delete (menu API) & the index (By Position)
or by command...
I hope this helps,