Windows API for return values

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top