|
Technical answers from the trenches |
|
Detecting a Form's Modality
| ||||
Posted: 7 November 2003 |
||||
  |
Applies to: All Versions |
|||
  |
Audience: Beginner |
|||
Question: How can I tell if a form is modal; that is, whether or not it was displayed with ShowModal?Answer: Check the form's FormState property for the fsModal member, as shown in the following code: procedure TForm1.FormShow(Sender: TObject); var blnIsModal : Boolean; begin // enable buttons according to form modality blnIsModal := fsModal in self.FormState; btnSave.Visible := not blnIsModal; btnClear.Visible := not blnIsModal; btnDelete.Visible := not blnIsModal; btnSelect.Visible := blnIsModal; btnCancel.Visible := blnIsModal; end; In this example, different buttons are displayed for different form states. This lets you design forms for different situations, which in turn reduces overall maintenance over time. Important: FormState isn't set until after the form is created; thus, you should not use this from a form's OnCreate event. Use the OnShow event instead. |
|||
|
||||||||
|
Copyright © 2000-2004, techtricks.com; All Rights Reserved. Acknowledgements, Disclaimers, Terms and Conditions. |
||||||||
|
Article last updated on 08 January 2004
|
||
|
|
||
|
[- End -]
|