See previous suggestions…
Set a local variable on your Close button and check it before closing the window. e.g. example from AI…
! Local Data
ClosedByCode BYTE(0)
! Inside your ACCEPT Loop / Event Handling:
CASE EVENT()
OF EVENT:CloseWindow
IF ClosedByCode = FALSE
! The user clicked the Red X, pressed Alt+F4, or used the System Menu
! Put your warning or cancellation logic here
IF Message('Do you really want to quit?', 'Confirm', ICON:Question, BUTTON:Yes+BUTTON:No, BUTTON:No) = BUTTON:No
CYCLE ! This CYCLE prevents the window from closing
END
END
BREAK
OF EVENT:Accepted
OF ?SaveAndCloseButton
ClosedByCode = TRUE
POST(EVENT:CloseWindow)
END