UserForm_QueryClose
在这种情况下不要使用。使用APIRemoveMenu
和GetSystemMenu
FindWindow
这是我最喜欢的 API 站点
删除菜单: http : //allapi.mentalis.org/apilist/RemoveMenu.shtml
获取系统菜单: http : //allapi.mentalis.org/apilist/GetSystemMenu.shtml
查找窗口: http : //allapi.mentalis.org/apilist/FindWindow.shtml
看这个例子
Option Explicit
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Const MF_BYPOSITION = &H400&
Private Sub UserForm_Initialize()
Dim Ret As Long
'~~> Change UserForm1 to match your userform's caption
Ret = FindWindow("ThunderDFrame", "UserForm1")
Do While Ret = 0
'~~> Change UserForm1 to match your userform's caption
Ret = FindWindow("ThunderDFrame", "UserForm1")
DoEvents
Loop
RemoveMenu GetSystemMenu(Ret, 0), 6, MF_BYPOSITION
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
截图: