Some of my forms can be shown both as normal and modal forms. In case they're showing as modal forms, I have to hide some components which are not usefull in modal state.
if(fsModal in Self.FormState) then
begin
//hiding some components...
end;
I would like to execute my code before the form is drawn, in order to avoid it's drawn more times unnecessarily.
I thought that OnShow executed before the form is visible, but it seems that is not so. So you can do this:
TMyForm = class( TForm ) // this will already be in your source
public
function ShowModal: Integer; override;
end;
function TMyForm.ShowModal: Integer;
begin
// hide some components
Result := inherited;
// show them again in case next time it is a Show
end;
You can't override Show in the same way - you would have to override the visible property, so easier to reset the visibility of the components as shown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With