[求助]点击窗体关闭钮如何实现弹出系统询问框?
下面是点击command1钮,则弹出系统询问的对话框,但如何实现点击窗体右上角关闭钮也会弹出这样的对话框?Private Sub Command1_Click()
Dim Ltem As Long
Dim LpID As Long
Dim hLong As Long
Dim strWinName As String
strWinName = "olp"
hLong = FindWindow(vbNullString, strWinName)
If hLong Then
GetWindowThreadProcessId hLong, LpID
Ltem = OpenProcess(PROCESS_TERMINATE, False, LpID)
TerminateProcess Ltem, 0
hLong = 0
End If
If MsgBox("你确实要退出吗?", vbYesNo + vbExclamation, "系统询问") = vbYes Then
Unload Me
End
Else
Cancel = True
End If
End Sub