GetSystemMenu,GetMenuItemCount,DrawMenuBar,RemoveMenu函数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 DrawMenuBar Lib "user32" (ByVal hwnd 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 Const MF_BYPOSITION = &H400&
Public Const MF_REMOVE = &H1000&
Public Const SC_CLOSE = &HF060
Public Const SC_MAXIMIZE = &HF030
Public Const SC_MINIMIZE = &HF020
Private Sub Command1_Click()
Dim hSysMenu As Long
Dim n As Long
hSysMenu = GetSystemMenu(Me.hwnd, False)
If hSysMenu Then
' 取得系统菜单中的数量
n = GetMenuItemCount(hSysMenu)
If n Then
RemoveMenu hSysMenu, n - 1, MF_BYPOSITION Or MF_REMOVE
'去掉 关闭 按钮
RemoveMenu hSysMenu, n - 2, MF_BYPOSITION Or MF_REMOVE
DrawMenuBar Me.hwnd
End If
End If
End Sub
Private Sub Command2_Click()
RemoveMenu GetSystemMenu(hwnd, 0), SC_MAXIMIZE, MF_REMOVE
End Sub
Private Sub Command3_Click()
RemoveMenu GetSystemMenu(hwnd, 0), SC_MINIMIZE, MF_REMOVE
End Sub
Private Sub Command4_Click()
RemoveMenu GetSystemMenu(hwnd, 0), SC_CLOSE, MF_REMOVE
End Sub
2,api:
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Dim hSysMenu As Long, nCnt As Long
hSysMenu = GetSystemMenu(Me.hWnd, False)
If hSysMenu Then
nCnt = GetMenuItemCount(hSysMenu)
If nCnt Then
RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE
RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE
DrawMenuBar Me.hWnd
End If
End If