Visible display form is really false, and the Hide call does nothing when the application is minimized because it is hidden by the application as part of the minimization mechanism.
ShowOwnedPopups code calls with the first 'False' as' bShow 'while the application is minimizing, and then with' True 'as' b Show while the application is being restored. Since the function shows all the windows that were hidden by the previous call, changing the visibility of the form between them has no effect.
Now, see this quote from the comments section of the function documentation,
if the popup is hidden using ShowWindow functions, subsequently calling ShowOwnedPopups using fShow the parameter set to TRUE does not call the displayed window
Thus, one of the solutions could be to hide the form before the application hides it, so it will not be displayed during recovery. But then we need to know whether the displayed form should really be hidden or shown during recovery. This can be achieved by placing the property in a display form or using a global variable. In the following, “ShouldBeVisible” is a hypothetical property that will return true if we want to display information:
type TForm1 = class(TForm) .. private procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND; ... procedure TForm1.WMSysCommand(var Msg: TWMSysCommand); begin if (Msg.CmdType = SC_MINIMIZE) and Assigned(Form2) and Form2.Visible then Form2.Hide; inherited; if (Msg.CmdType = SC_RESTORE) and Assigned(Form2) and Form2.ShouldBeVisible then Form2.Show; end;
Sertac akyuz
source share