Re: Making Delphi program POP UP.

Posted by webmaster Guido on April 03, 2001 at 22:48:27:

In Reply to: Making the program POP UP. posted by James McLain on March 28, 2001 at 07:47:25:

: There seems to be a bug in the FormState property or forms. I have an app that I would like to POP UP. Setting the window stat to fsNormal, does nothing if the form is minimized. But changing to fsMaximized does work. So what I am doing in my code is making the form invisible, maximizing it, and the normalizing it, the making it visible again. This works BUT. For some reason after I do this, the minimize button on the form doesn't work anymore. Anyone know why this is, and how I can correct it? Here's my code:

If not then
Convo.Visible := false;
Convo.WindowState := wsMaximized;
Convo.WindowState := wsNormal;;

: convo is the name of the form I'm poping up.

Setting the window state to fsNormal only restores the form if the form was minimized with TheForm.WindowState := wsMinimized.
On the other hand, if you minimize the application, then you have to restore the applic ation with Application.Restore.
And if you "hide" a form (with TheForm.Hide or with TheForm.Visible := False), then you make it visible again (with TheForm.Show or with TheForm.Visible := True).

The confusion starts with this: when you minimize the application, all of its windows (forms) disappear. If there is only one window, it gives the impression that this window is "minimized" or that it is "hidden". But in fact, none of these two is the case. By lack of a better word, let's say that all the windows temporarily "disappear" until the application is restored again.

To add to the confusion, the application can be minimized in two different ways:
- either because of a call to the Application.Minimize method;
- or because the user minimizes the main form by clicking its Minimize button or through its System menu. In this last case, there will not be an automatic WindowState := wsMinimized, but Application.Minimize will be called automatically!

So, the code for "restoring" the mai n form depends from was whether your application was minimized, or your main form was minimized, or your main form was hidden. The following example will allways "pop up" the main form, because it checks both the state of the application and the state of the form:

if not Application.Active then
if not FormMain.Visible then
if FormMain.WindowState <> wsNormal then
  FormMain.WindowState := wsNormal;


Related Articles and Replies: