Board index » delphi » Minimizing forms in D2

Minimizing forms in D2

I need to execute some code when the user minimises a form, but *before*
the form actually minimises. I have tried to check WindowState in the
OnResize event, as there is no OnMinimise event, but this executes after
the form visibly minimises.

What I am actually trying to do is hide the form before the user sees it
minimise. I also need to resize a form as it is created, but without the
user seeing the resize. Is there any way I can do this?

Thanks, Andy

--= email: aing...@clara.net =--------------------= irc: Polyhedra =--
 "Wow!  It works both ways!  That's some chicken."
   - Guybrush Threepwood
------------------= http://home.clara.net/aingham =-------------------

 

Re:Minimizing forms in D2


Quote
Andy Ingham wrote:
> I need to execute some code when the user minimises a form, but *before*
> the form actually minimises. I have tried to check WindowState in the
> OnResize event, as there is no OnMinimise event, but this executes after
> the form visibly minimises.

> What I am actually trying to do is hide the form before the user sees it
> minimise. I also need to resize a form as it is created, but without the
> user seeing the resize. Is there any way I can do this?

Do this:

Procedure TForm1.WMSysCommand (Var Msg : TMessage);
Begin
  If (Msg.WParam = 61472) Then
  Begin
    { code before minimizing the window }
  End;

  Inherited; { don't forget! }
End;

In the public part of the "TForm1"-class insert:

Procedure WMSysCommand (Var Msg : TMessage); Message WM_SysCommand;

beni

--
|          ORDER WEBPAGE COMPOSER NOW! ONLY 20.00 CHF.         |
|             http://www.gse.ch/benimedia/wpc1x.htm            |
|                                                              |
| Benjamin Stengl, Schulstrasse 23, CH-5525 Fischbach-G?slikon |

Re:Minimizing forms in D2


If you want to receive or intercept messages coming to your app (for
example, minimize message(s)) before the form actually minimizes, a sure
way would be to subclass your form and look for the appropriate messages.
Another way, which I'm not sure will work or not, is to set up message
handlers for the particular message(s) in your form so you can intercept
them.  One last thing to look at is the Application.OnMinimize event.  May
not be what you want, but something to look into.
Also, about resizing your form as its being created so the user can't see
it being resized, why not just set the clientheight and clientwidth of the
form in the OnCreate event?

Good Luck,
Jay

Other Threads