Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My APP stays in Memory when I close it using the X... WHY? PLZ HELP

Status
Not open for further replies.

Zasx

Technical User
Jun 18, 2002
11
US
Have you seen an app. where you click on the X in the title bar to kill the app, the app display goes away, but when you look at the NT task manager the application shows as still running.
Is this a memory leak?

Is their a way to fix it? If not how do I disable the Title bar resize/close icons, or not show the title bar at all.

Thanks
Dan
 
Hi Dan,

(Presuming that this is an app that you have written yourself using vb:)

Maybe all of your forms have not been unloaded :

' put this in the Form_Unload section of the startup form

dim oF as Form

for each oF in Forms
unload oF
next
 
Yes it is an app I wrote, I will try your suggestion and let you know.
 
It worked thanks,

Wait I just realized now that when you close the app this way it leaves some work undone since it did not exit properly. Is their a way to disable the X?
 
Private Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, _
ByVal bRevert As Long) As Long

Private Declare Function RemoveMenu Lib "user32" _
(ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long

Private Const POSITION = &H400&

Public Function DisableX(frm As Form) As Boolean
Dim Test As Long, Test2 As Long, Test3 As Long
Test = GetSystemMenu(frm.hwnd, 0)
Test2 = RemoveMenu(Test, 6, POSITION)
Test3 = RemoveMenu(Test, 5, POSITION)
DisableX = (Test2 <> 0 And Test3 <> 0)

End Function

Private Sub Form_Load()
DisableX Me
End Sub
Swi
 
When I want to let a user exit using the X but also want to force my program to close cleanly, I call any exit routines from the form_unload event of the main program form. This is also a good way of making sure the user had saved anything that may need to be saved as you can cancel the unload event.

Matt
 
You guys ROCK!

Thanks for all the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top