Below code is for VB6. You may upgrade the code to .NET too.
Put the below function in a module level.
Public Function RemoveXButton(frmWindow as Form)
dim hMenu as Long
dim nCount as Long
hMenu=GetSystemMenu(frmWindow.Hwnd,0)
nCount=GetMenuItemCount(hMenu)
'Remove the last two menu items which are a seperator and Alt+F4
Call RemoveMenu(hMenu ,nCount-1, MF_REMOVE OR MF_BYPOSITION)
Call RemoveMenu(hMenu, nCount-1, MF_REMOVE OR MF_BYPOSITION)
DrawMenuBar frmWindow.hWnd
End Function
'Declarations
Public Declare Function GetSystemMenu Lib "User32" (byval hwnd as Long, byval bRevert as Long) as Long
...
Public Const MF_BYPOSITION = &H400&
Public Const MF_REMOVE = &H1000&
Similar to GetSystemMenu, search over internet and get declarations for GetMenuItemCount, RemoveMenu and DrawMenuBar.
Thanks and Good luck
Enter your message below
Sign in or Join us (it's free).