VB的源代码: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 Const MF_BYPOSITION = &H400& Const MF_REMOVE = &H1000& Private Sub Form_Load() Dim hSysMenu As Long, nCnt As Long ' Get handle to our form's system menu ' (Restore, Maximize, Move, close etc.) hSysMenu = GetSystemMenu(Me.hwnd, False) If hSysMenu Then ' Get System menu's menu count nCnt = GetMenuItemCount(hSysMenu) If nCnt Then ' Menu count is based on 0 (0, 1, 2, 3...) RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE ' Remove the seperator DrawMenuBar Me.hwnd ' Force caption bar's refresh. Disabling X button Me.Caption = "Try to close me!" End If End If End Sub哈,我厉害吧,给分吧 。
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
Const MF_BYPOSITION = &H400&
Const MF_REMOVE = &H1000&
Private Sub Form_Load()
Dim hSysMenu As Long, nCnt As Long
' Get handle to our form's system menu
' (Restore, Maximize, Move, close etc.)
hSysMenu = GetSystemMenu(Me.hwnd, False) If hSysMenu Then
' Get System menu's menu count
nCnt = GetMenuItemCount(hSysMenu)
If nCnt Then
' Menu count is based on 0 (0, 1, 2, 3...)
RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE
RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE ' Remove the seperator
DrawMenuBar Me.hwnd
' Force caption bar's refresh. Disabling X button
Me.Caption = "Try to close me!"
End If
End If
End Sub哈,我厉害吧,给分吧 。
对了,老兄,我发现将窗口的controlbox属性设为false即可去除所有的按钮!!