في الـ module ...
Public Declare Function GetSystemMenu Lib "user32" ( _ ByVal hwnd As Long, _ ByVal bRevert As Long) As Long Public Declare Function GetMenuItemCount Lib "user32" ( _ ByVal hMenu As Long) As Long Public 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 Long) As Long Public Const MF_BYPOSITION = &H400& Public Const MF_DISABLED = &H2& Public Sub DisableX(frm As Form) Dim hMenu As Long, nCount As Long 'Get handle to system menu hMenu = GetSystemMenu(frm.hwnd, 0) 'Get number of items in menu nCount = GetMenuItemCount(hMenu) 'Remove last item from system menu (last item is 'Close') Call RemoveMenu(hMenu, nCount - 1, MF_DISABLED Or MF_BYPOSITION) 'Redraw menu DrawMenuBar frm.hwnd End Sub
في الفورم ...
DisableX Me