I have a generic procedure that allows me to close forms during the OnShow event if, for example, it proves impossible to open databases or some other problem means that I do not wish the form to complete its display.
This works perfectly well, but gives a flash of the window caption bar which looks awful. I cannot hide the window if it is an MDI form... My code:
procedure ForceFormClose(Form: TForm);
with Form do
// Disable any Resize processing for form
OnResize := NIL;
// Zero form size
Height := 0;
Width := 0;
// minimize form
WindowState := wsMinimized;
// Despatch Close message
PostMessage(Handle, WM_CLOSE, 0, 0);
How can I get rid of the flash?