Cancel/Close

I have the following in the cancel/close event but when I click the window close button just the window closes and I am wanting the app to quit as there is only ever 1 window. Is there another event I should be working in or am I in the right place but not got the following right?

if gsaved = false then
dim oDlg as new MessageDialog
oDlg.Message = “Do you want to save changes to this document before closing?”
oDlg.Explanation = “If you don’t save, your changes will be lost.”
oDlg.ActionButton.Caption = “&Save”
oDlg.CancelButton.Caption = “Cancel”
oDlg.CancelButton.Visible = true
oDlg.AlternateActionButton.Caption = “&Don’t Save”
oDlg.AlternateActionButton.Visible = true

dim oBtn as MessageDialogButton = oDlg.ShowModalWithin(self)

select case oBtn
case oDlg.ActionButton
// Save
if gsaved = false then
if uppercase(right(currentfile,8)) = “.CWPTEXT” then
SavePCW
else
SavePCW1
end if
else
end if
return false

case oDlg.CancelButton
// Cancel close
return true
case oDlg.AlternateActionButton
// Don’t Save
end select
else
return false
end if

the APP cancelClose or the WindowCancelClose event?

If the APP cancelClose, that won’t even be called unless the APP is closing, and if you have other windows open and App.AutoQuit is not true, then this event won’t be called, and just the Window will close, and if AutoQuit is false, then the app won’t quit automatically regardless of the number of open windows

If in the Window cancelClose… all you could do is cancel closing the Window.

I have it in the Window Cancel/Close

So how do I signal the App to quit and close the window after it does my save?

issue the QUIT command

If you want your app to quit automatically when no windows are open (without having to write an explicit Quit command), then simply include this line in the Open event when the app opens:

App.AutoQuit = true