Quit in CancelClose windows event shows dialogue twice (was: Process not removed on quit).

I have just compiled my first windows program (originally a small listbox database of mine for mac).
Every time I run it (on windows) a new process of the program is added and quitting the program does not remove it. The program is quit via the standard dropdown menu. The menuhandler>Quit contains only quit.

What do I do to close my program so that the process is removed also.

I compiled with the latest Xojo on a Mac and ran my program on win7. Last time I looked in the windows activity monitor I had 20 processes of my program taking up space and I had to kill them manually.

On the Mac no problems.

does it start another process? if it does you need to kill that first otherwise it’ll never stop

Sounds like you might be in MDI mode. Try ‘App.AutoQuit = True’

For some reason I closed the window to quit on windows and the menu to close on Mac. Sigh. My error is on both platforms…

The problem is that the example code I stole and put in the window cancelclose event does not actually close the app, just the window after running the message dialogue.
So I tried adding quit, but when I do the quit retriggers itself and the (save, don’t save, cancel) dialogue, shows up twice.
(If I quit via the drop down menu it works as it should, just the dialogue once and then it quits.)

When quitting by closing the window. Do I use quit to kill the process? And where do I put it, to get rid of the message dialogue showing itself twice?
I tried to move “quit” to the close event, but the result is the same.

[code]Dim md as New MessageDialog //declare the MessageDialog object
Dim mb as MessageDialogButton //for handling the result
md.icon=MessageDialog.GraphicCaution //display warning icon
md.CancelButton.Visible=True //show the Cancel button
md.AlternateActionButton.Visible=True //show the “Don’t Save” button
md.AlternateActionButton.Caption=“Don’t Save”
md.Message=“Do you want to save changes to this document before closing?”
md.Explanation="If you don’t save, your changes will be lost. "

mb=md.ShowModal //display the dialog
Select Case mb //determine which button was pressed.

Case md.ActionButton
//user pressed Save

  Return False       
  Return True          'just skip out

Case md.AlternateActionButton
//user pressed Don’t Save
’ some code before qutting
Return False

Case md.CancelButton
//user pressed Cancel
Return True
End select[/code]

(All there is in Menu Handels / Quit, is quit.)
Later: Rephrasing my search I now found that this problem is ancient… Still trying to find a solution…
Later2: OK. Quit (in the dropdown menu) fires Application CancelClose Event, then Window CancelClose Event (when closing the window). Trying to close the Window fires only Window CancelClose Event. By adding quit to the window CancelClose Event, then the Application CancelClose event is fired, then… So I got figure things out how to move things around to not get things done more than once, to get around Xojo being helpful and doing things for me…

properly used APP.AUTOQUIT=TRUE (in the app.open event) is all you need in most cases…

I would avoid the QUIT command as it takes away a large amount of control on how graceful you app quits.

Use CANCELCLOSE to stop a window from closing, and do each windows cleanup (if required) in the CLOSE event

Then when the last window has been closed, the app will quit.

Stark contrast to iOS apps that are not “allowed” to quit themselves…

Same thing for Android and Windows Phone. And because Microsoft people have no brains, new API desktop apps (they call them “Windows Store” apps theses days, after “Metro”) have the very same limitation. So when you launch several Windows 8 specific apps, they remain stuck to your PC like ticks on a dog.

Ahh! I had a “window2” in the program, which was hidden. I had completely forgot that I used window.hide on that one.
window2.close made it work…

OK. Thanks!

Should I have been able to see somewhere that there was a second window not closed (other than finding it in my code)?

The debugger would show you that.