回復 1#hugh0620
請詳看 VBA [QueryClose 事件] 的說明
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub作者: hugh0620 時間: 2011-5-11 11:48
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_style = (-16)
Private Const CLOSEBOX As Long = &H80000
Private Sub UserForm_Initialize()
Dim hWndform As Long
Dim Istyle As Long
hWndform = FindWindow("Test", Me.Caption)
Istyle = Istyle And Not CLOSEBOX
SetWindowLong hWndform, GWL_style, Istyle
End Sub