Hi, I am developing a visual basic application. I have implemented no modal msgbox as following:
VB Code:
Option Explicit Private Declare Function MsgboxNoModal Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long Const MB_ICONASTERISK = &H40& Private Sub NoModalMsgboxExample() Call MsgboxNoModal(100, "This is NO modal.", "No Modal Msgbox Example", MB_ICONASTERISK) End Sub
This works ok. The problem is that if I dont close all the message boxes that appear during execution of the application, when I finish the application it keeps on standby until I close all the message boxes, and then finishes.
If I add the following code I only close the last msgbox opened, but I would like to close all the message boxes that remain opened. Is there any way to close automatically all the message boxes that remain opened when I finish the application?
VB Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 Const WM_CLOSE = &H10 Private Sub Close_application() Dim hWnd As Long hWnd = FindWindow("#32770", "No Modal Msgbox Example") SendMessage hWnd, WM_CLOSE, 0, 0 End End Sub
I am a beginner using API, so I would appreciate any help. Thank you very much for your help!!!




Reply With Quote