Loading...
 

CloseWindow

CloseWindow

CloseWindow(windowID), CloseWindow(windowID, flag), CloseWindow(, flag), CloseWindow

Parameter: windowID: Identifier of a Windows or ALL

Stack
Stack Position Description
Stack(In) Top -
Stack(Out) Top -

The window identified by windowID is closed. For windowID you can specify ALL to close all open windows.

ClassiX® delays the closing of the window so that subsequent instructions referring to the window or one of its child objects do not lead to an error (internally a CloseWindow2 instruction is generated). This has the following side effect: If for some reason the execution of the following InstantView statements is aborted (e.g. if an error occurs between the call of CloseWindow and the actual closing, or if the cancel command is executed), the window will not be closed. If - regardless of the further course of the code execution - the window is to be closed immediately, the parameter IMMEDIATELY must be specified.

When a window is closed, the message CLOSE is sent. Afterwards the window and the active widget in the window get the message NON_CURRENT. A cancel within CLOSE or NON_CURRENT only aborts the processing of the current message, but does not prevent the window from closing. If an error occurs during the processing of these messages, ClassiX writes a crash dump and ends immediately with a crash message. This behaviour is intentional and analogous to exceptions in destructors in C++.

After CloseWindow is called on a window, further calls on the same window are ignored. The same happens if CloseWindow is called on a window that is not open at all.

Flags
Flag Meaning
NO_DRAIN This flag is only useful for those windows that are connected with the OboxEdit instruction. Via NO_DRAIN it is determined whether the automatic writing back of changes into the window (by an implicit DrainWindow) should be suppressed.
IMMEDIATELY Closes the window immediately (and not delayed, see above) This flag should be used in two cases:
  • The window should be closed in any case, even if the InstantView command sequence is aborted by an error
  • To save resources (or to release them immediately, e.g. in automatic tests where many windows are opened)

Example

Both buttons in the following example close the window. However, the order of the attention messages is different.

Window(EditWin, 310, 87, 500, 60, T("Eingabefenster", "Input Window")) [ CLOSE: "Msg CLOSE" Attention ] { Button(Close, 10, 10, 200, T("Schließen", "Close")) [ SELECT: CloseWindow "Close" Attention // "Close" kommt vor "Msg CLOSE" ] Button(CloseIMMEDIATELY, 10, 20, 200, T("Sofort Schließen", "Close Immediately")) [ SELECT: CloseWindow(EditWin, IMMEDIATELY) "CloseIMMEDIATELY" Attention // "CloseIMMEDIATELY" kommt nach "Msg CLOSE" ] }