VB Code:
'In a module 'Call from any form, passing the Form object Option Explicit On Private Const MF_DISABLED = &H2& Private Const MF_BYPOSITION = &H400& Private Declare Function GetSystemMenu Lib "user32.dll" (ByVal hwnd As Int32, ByVal bRevert As Int32) As Int32 Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Integer) As Integer Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Integer) As Integer Public Function DisableX(ByRef oForm As System.Windows.Forms.Form) '<VB/OUTLOOK GURU 11/09/2004 - REMOVES FORM SYSTEM MENU ITEMS BY POSITIONS> Dim hMenu As Int32 Dim nCount As Integer hMenu = GetSystemMenu(oForm.Handle.ToInt32, 0) nCount = GetMenuItemCount(hMenu) Call RemoveMenu(hMenu, nCount - 1, MF_DISABLED Or MF_BYPOSITION) nCount = GetMenuItemCount(hMenu) Call RemoveMenu(hMenu, nCount - 1, MF_DISABLED Or MF_BYPOSITION) Call DrawMenuBar(oForm.Handle.ToInt32) End Function





Reply With Quote