Click to See Complete Forum and Search --> : unloading child with parent
conniek
May 9th, 2001, 01:46 PM
I have set my vb program to be a child of an off-the shelf contact management program called GoldMine. When I close the parent, my program seems to go away but it is actually still running and I can see it in task manager. How can I tell my program to end with the parent without being able to change the programming of the parent itself?
Megatron
May 9th, 2001, 03:50 PM
You could use FindWindowEx to search for the parent window, and if it's not found, then send the WM_QUIT message (via PostQuitMessage) to your App.
conniek
May 10th, 2001, 09:16 AM
How do I trigger that?
Megatron
May 10th, 2001, 04:35 PM
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
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
Priavte Sub Timer1_Timer
hApp = FindWindowEx(0, 0, "ClassName", "Title")
If hApp = 0 Then PostQuitMessage(0)
End Sub
Careful not to do this in the IDE, however, because it will end VB as well.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.