
November 21st, 2002, 09:06 PM
|
|
Mc-Chin
|
|
Join Date: Aug 2001
Posts: 86
Time spent in forums: 2 h 21 m 50 sec
Reputation Power: 12
|
|
Hi All,
Hope someone can provide more info on closing VB apps.
I have an application with dozens of forms and child forms, and using over 20 OCXs...once compiled the exe is around 10 MBs..
under development environment i can "End" the application properly....but when compiled and execute it, when i end the application, all the forms are gone, but under the "Task Management" utility in win2000 (CTRL + ALT + DEL) i can still see my app is running.
in my MDI parent form_unlod, i use
PHP Code:
for each obj in forms
Unload obj
next
end
but after some reading and etc... i used
PHP Code:
Public Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Declare Function PostMessageByNum& Lib "user32" Alias _
"PostMessageA" (ByVal hwnd As Long, ByVal wMsg As _
Long, ByVal wParam As Long, lParam As Long)
Const WM_CLOSE = &H10
Const TARGET_CLASS_NAME = "ThunderRT6Main"
Const TARGET_WINDOW_TEXT = "Project1"
....Form Unload event (MDI parent)....
for each obj in forms
Unload obj
next
hTarget = FindWindow(TARGET_CLASS_NAME , TARGET_WINDOW_TEXT)
' The following line will close the app.
' You could instead set up a subclasser here.
If hTarget Then Call PostMessageByNum(hTarget, WM_CLOSE, 0, 0)
end
with the above, i can end the VB App.
any comments?
Thanks and Best Regards
__________________
|