|
-
May 13th, 2001, 10:12 AM
#1
-
May 13th, 2001, 11:18 AM
#2
PowerPoster
Yes, tried but of no use. Or maybe I ma not using the right sequence. What's the right sequence? I will the post the code in a few minutes.
-
May 13th, 2001, 11:28 AM
#3
PowerPoster
I will post the code a little later(hour or two) as i have to go for
some urgent work right now.
-
May 13th, 2001, 12:16 PM
#4
The correct order should be:
WM_CLOSE
WM_DESTROY
WM_NCDESTROY
WM_QUIT
-
May 13th, 2001, 02:57 PM
#5
PowerPoster
Still doesn't work in some cases. I have explained in the comments
Code:
Option Explicit
Private Declare Function DestroyWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindowEx Lib "user32" _
Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Dim lngHwndMsgBox As Long
Dim lngRV As Long
Private Const WM_CLOSE = &H10
Private Const WM_DESTROY = &H2
Private Const WM_NCDESTROY = &H82
Private Const WM_QUIT = &H12
Private Sub Command1_Click()
lngHwndMsgBox = FindWindowEx(0&, 0&, vbNullString, "Test MsgBox")
'Send Message with WM_CLOSE
'works on vbOkOnly,vbOkCancel,vbYesNoCancel & vbRetryCancel buttons MsgBox
'All the above working MsgBox conditions have "Esc" key enabled
'doesnot work on vbAbortRetryIgnore and vbYesNo
'lngRV = SendMessage(lngHwndMsgBox, WM_CLOSE, 0&, 0&)
'Kills all MsgBoxes, but the application stops responding
lngRV = SendMessage(lngHwndMsgBox, WM_CLOSE, 0&, 0&)
lngRV = SendMessage(lngHwndMsgBox, WM_DESTROY, 0&, 0&)
lngRV = SendMessage(lngHwndMsgBox, WM_NCDESTROY, 0&, 0&)
lngRV = SendMessage(lngHwndMsgBox, WM_QUIT, 0&, 0&)
End Sub
-
May 17th, 2001, 08:20 PM
#6
PowerPoster
Any ideas. Do I need to put it in a Do..While loop
-
May 18th, 2001, 12:30 AM
#7
Registered User
What do you want to do? If you want to click a button may use once you have the hwnd of the button:
Private Declare Function PostMessage Lib _
"user32" Alias "PostMessageA" (ByVal hWnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) _
As Long
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const MK_LBUTTON = &H1
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_RBUTTONUP = &H205
Private Const MK_RBUTTON = &H2
-
May 18th, 2001, 02:51 PM
#8
PowerPoster
Yes, thats certainly a way. I can even send a BM_CLICK message to the command button. But what i want to know is why does it work in some cases, while in others it doesn't.
-
May 18th, 2001, 06:32 PM
#9
Registered User
I cam confirm the behaviour, and even tried it in a do while loop, but still no luck closing msgboxes using that approach.
-
May 20th, 2001, 10:07 PM
#10
Registered User
amitabh,
I found out why...
Sending the wm_close to the window is the equivalent of clicking the "x" on the form.
Now, check out the state of the "x" on a vbyesno message box...it is disabled, so you can't close such a message box this way.
You will have to find the hwnd of the button and click either yes or no.
-
May 21st, 2001, 01:43 AM
#11
PowerPoster
Oh good
Thanks
But what about WM_Quit, Wm_Destroy, WM_NCDestroy. Why aren't they working. Anyway
I have implemented this through clicking of command buttons
-
May 21st, 2001, 02:58 AM
#12
Registered User
Perhaps you could also use:
Code:
Private Declare Function TerminateProcess& Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|