Hi Guys,
I thought this was something easy: alter the behaviour of the Close box, the "X" in the upper right corner of a form.
I want to minimize the form instead when the user clicks the X (or maybe do something else no matter what).
I have a Quit button elsewhere on the form with a "Release Thisform" command.
I put this in the QueryUnload event.
That works fine. The problem however is the Nodefault instruction.
When the user selects "Close Window" in the popup menu on the taskbar icon of my program, Windows evokes the QueryUnload event too, resulting in Nodefault and a lot of strange things happen, like a grid that becomes empty. Or when I Shutdown Windows while the app is still running, It shows up as "A program preventing the shutdown".
I want Windows to be able to nicely shutdown the running application, which works great when nodefault is not used in QueryUnload....
So how to make QueryUnload aware of the difference between an users X click or Windows closing the app?
Or is there any other way to alter the behaviour of the Close button (or Alt+F4) by not using QueryUnload?
And Yes I know I can set CloseBox to .f. te prevent the user clicking at all, but that is not what this question is about.
B.t.w. this is a simplefied main.prg example:
I thought this was something easy: alter the behaviour of the Close box, the "X" in the upper right corner of a form.
I want to minimize the form instead when the user clicks the X (or maybe do something else no matter what).
I have a Quit button elsewhere on the form with a "Release Thisform" command.
I put this in the QueryUnload event.
Code:
thisform.windowstate=1 && minimized
nodefault
That works fine. The problem however is the Nodefault instruction.
When the user selects "Close Window" in the popup menu on the taskbar icon of my program, Windows evokes the QueryUnload event too, resulting in Nodefault and a lot of strange things happen, like a grid that becomes empty. Or when I Shutdown Windows while the app is still running, It shows up as "A program preventing the shutdown".
I want Windows to be able to nicely shutdown the running application, which works great when nodefault is not used in QueryUnload....
So how to make QueryUnload aware of the difference between an users X click or Windows closing the app?
Or is there any other way to alter the behaviour of the Close button (or Alt+F4) by not using QueryUnload?
And Yes I know I can set CloseBox to .f. te prevent the user clicking at all, but that is not what this question is about.
B.t.w. this is a simplefied main.prg example:
Code:
ON SHUTDOWN do quitform && does a clear events and a release windows
do form testclos
read events
ON SHUTDOWN