哦,对不起,题目没有看全!!!!!!!!!!!!!!! 在另外一个帖子中抄了阿甘的代码,试试看/:Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long Const MF_BYCOMMAND = &H0& Const MF_REMOVE = &H1000& Const MF_BYPOSITION = &H400&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
gump2000(阿甘) ,我是用在MDI窗体中呢!要不我问这个题目干什么呀!
这段代码是最大化按钮没有作用,但没有灰掉。Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long Const MF_BYCOMMAND = &H0& Const MF_REMOVE = &H1000& Const MF_BYPOSITION = &H400&Private Sub mdiForm_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 RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION Or MF_REMOVE ' DrawMenuBar Me.hwnd ' Force caption bar's refresh. Disabling X button 'Me.Caption = "Try to close me!" End If End If End Sub
combread(大点) ,这个代码我试过了,它只是灰掉了关闭按钮而已呢!
MDI的话,就用上面代码嘛 不灰掉但是已经不起作用了:)
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long Const MF_BYCOMMAND = &H0& Const MF_REMOVE = &H1000& Const MF_BYPOSITION = &H400& Private Sub MDIForm_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 RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION Or MF_REMOVE ' DrawMenuBar Me.hwnd ' Force caption bar's refresh. Disabling X button 'Me.Caption = "Try to close me!" End If End If LoadNewDoc End Sub 没有啊!!! 绝对可以执行啊
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long Const MF_BYCOMMAND = &H0& Const MF_REMOVE = &H1000& Const MF_BYPOSITION = &H400& '''' 'API申明,没有什么好说的吧 '''' Private Sub MDIForm_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)'获取本form的menu的句柄 If hSysMenu Then ' Get System menu's menu count nCnt = GetMenuItemCount(hSysMenu)'获取menu的item count If nCnt Then ' Menu count is based on 0 (0, 1, 2, 3...) RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION Or MF_REMOVE'把倒数第三个menu给delete掉 End If End If LoadNewDoc End Sub
在另外一个帖子中抄了阿甘的代码,试试看/:Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Const MF_BYCOMMAND = &H0&
Const MF_REMOVE = &H1000&
Const MF_BYPOSITION = &H400&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 RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Const MF_BYCOMMAND = &H0&
Const MF_REMOVE = &H1000&
Const MF_BYPOSITION = &H400&Private Sub mdiForm_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
RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION Or MF_REMOVE
' 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 RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Const MF_BYCOMMAND = &H0&
Const MF_REMOVE = &H1000&
Const MF_BYPOSITION = &H400&
Private Sub MDIForm_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
RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION Or MF_REMOVE
' DrawMenuBar Me.hwnd
' Force caption bar's refresh. Disabling X button
'Me.Caption = "Try to close me!"
End If
End If LoadNewDoc
End Sub
没有啊!!!
绝对可以执行啊
除非您在您的loadnewdoc代码中写了什么
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Const MF_BYCOMMAND = &H0&
Const MF_REMOVE = &H1000&
Const MF_BYPOSITION = &H400&
''''
'API申明,没有什么好说的吧
''''
Private Sub MDIForm_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)'获取本form的menu的句柄
If hSysMenu Then
' Get System menu's menu count
nCnt = GetMenuItemCount(hSysMenu)'获取menu的item count
If nCnt Then
' Menu count is based on 0 (0, 1, 2, 3...)
RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION Or MF_REMOVE'把倒数第三个menu给delete掉
End If
End If LoadNewDoc
End Sub
MF_BYPOSITION '按照位置来计算