J
Jac Tremblay
Hi,
I found out how to find the name of the application that displays the exit
warning message (see code below), but I would like to go further and detect
which button the user clicks (particularly the cancel button). Is that
possible? Maybe with some other API function(s)?
' *********************************************************
Declare Function GetActiveWindow Lib "user32" () As Long
' *********************************************************
Public Function ActiveWindowCaption() As String
Dim strCaption As String
Dim lngLen As Long
strCaption = String$(255, vbNullChar)
lngLen = Len(strCaption)
If (GetWindowText(GetActiveWindow, strCaption, lngLen) > 0) Then
ActiveWindowCaption = strCaption
End If
End Function
' *********************************************************
Private Sub cmdGetActiveWindow_Click()
Dim hwnd As Long
hwnd = GetActiveWindow()
MsgBox "Window handle : " & hwnd & vbCrLf & vbCrLf & _
"Window caption : " & ActiveWindowCaption
End Sub
The message box shows the long number for the window handle and the name
"Microsoft Excel".
I would like to get the return value of the button click so that I can act
accordingly.
Thanks for any help.
I found out how to find the name of the application that displays the exit
warning message (see code below), but I would like to go further and detect
which button the user clicks (particularly the cancel button). Is that
possible? Maybe with some other API function(s)?
' *********************************************************
Declare Function GetActiveWindow Lib "user32" () As Long
' *********************************************************
Public Function ActiveWindowCaption() As String
Dim strCaption As String
Dim lngLen As Long
strCaption = String$(255, vbNullChar)
lngLen = Len(strCaption)
If (GetWindowText(GetActiveWindow, strCaption, lngLen) > 0) Then
ActiveWindowCaption = strCaption
End If
End Function
' *********************************************************
Private Sub cmdGetActiveWindow_Click()
Dim hwnd As Long
hwnd = GetActiveWindow()
MsgBox "Window handle : " & hwnd & vbCrLf & vbCrLf & _
"Window caption : " & ActiveWindowCaption
End Sub
The message box shows the long number for the window handle and the name
"Microsoft Excel".
I would like to get the return value of the button click so that I can act
accordingly.
Thanks for any help.