Trigger Event When minimising Form

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Trigger Event When minimising Form

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:44 pm

by Martin >> Tue, 26 Aug 2003 4:51:36 GMT

Hi Everyone

Can someone please tell me how i can trigger an event when a user presses the Minimise button on a form?

Thanks

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Trigger Event When minimising Form

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:44 pm

by cnwsvm1 >> Tue, 26 Aug 2003 22:35:44 GMT

Take a look at the help entry for the windowState property of Form. It says:

Type: Integer
Availability: Read or write at any time

The windowState property of the Form class contains the visual state of a form window at run time.
The settings of the windowState property are listed in the following table.

WindowState_Normal 0 Normal (the default)
WindowState_Minimized 1 Shrunk to an icon
WindowState_Maximized 2 Enlarged to maximum size

Minimizing a form causes a resize event. The size of the form and its controls reflects the minimized state.
The following example shows the use of the windowState property.

resize() updating;begin

if windowState <> WindowState_Minimized then // restore after minimize
caption := "CD Player";
endif;

end;

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Trigger Event When minimising Form

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:44 pm

by cnwsvm1 >> Tue, 26 Aug 2003 23:05:41 GMT

OK, so the example in the help file is a bit lame.

The comment suggests that if windowState is not minimized then it has just been restored, but of course there are all sorts of other resizes that could trigger the resize event.

You might prefer to put an integer property on your superclass form (previousWindowState) and code the resize event on the superclass to detect when the windowState first becomes minimised - call your own method (formMinimised) which you can reimplement in your form subclasses.

resize() updating;begin

if windowState <> previousWindowState and windowState = WindowState_Minimized then
formMinimised;
endif;
epilog
previousWindowState:=windowState;
end;

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Trigger Event When minimising Form

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:44 pm

by Martin >> Wed, 27 Aug 2003 3:19:44 GMT

Thank you so much for that. :) everything is working brilliantly:)


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 14 guests