Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.NET not removing Close from System Menu under XP

Status
Not open for further replies.

MAKNIGHT71

IS-IT--Management
Sep 25, 2003
67
US
The old code I have used in the past does not appear to work under either Windows XP or VB.NET. I'm not certain which is the culprit. The following code has always removed the Close System Menu item for me, but it is only removing the separator no matter what the position value is. It appends a new menu item just fine.

maknight

' External system DLL function declarations
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Integer, ByVal bRevert As Boolean) As Integer
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu 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 RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Public Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Integer) As Integer

' External system constants declaration
Private Const MF_BYPOSITION = &H400
Private Const MF_REMOVE = &H1000
Private Const WM_SYSCOMMAND = &H112


' Remove Close system menu item and add menu item(s)
Dim hSysMenu As System.Int32 = GetSystemMenu(Me.Handle.ToInt32, False)
RemoveMenu(hSysMenu, (GetMenuItemCount(hSysMenu) - 1), MF_BYPOSITION)
AppendMenu(hSysMenu, 0, 1000, "View DWG Database...")
DrawMenuBar(Me.Handle.ToInt32)
 
I have verified that it is an issue with VB .NET 2003. The system menu code acts the same running under Windows 98 when compiled with VB .NET 2003.

maknight
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top