making mdi child forms MODAL

making mdi child forms MODAL

--------------------------------------------------------------------------------
You can not show a MDIChild form as modal. their formStyle should be set
to fsNormal
I have solved this problem in the following way.

I have (I should have) an ancestor form in my project which is the
father of all other forms in the project. In the CreateParams method of this
form I set the FormStyle := fsMDIChild and Visible := true
I have another form as ancestor of all modal forms in the project which
is itself a descendant of the main ancestor form. In the create params of
that form I set FormStyle := fsNormal and Visible := false. Why I set
visible := false here, because when you use the ShowModal method to show a
form as modal your form must not be visible otherwise you will get the
exception "can not show as modal a visible form" something like that and
if you create the form in visible state and then hide it and show it as
modal, your modal forms will be flickering at creation time, especially on
slow machines
Now, it happens that in my project I open the same form as modal and
modless in some cases. The only way I could solve this problem was by using
a global variable (the only one in the whole project) which I use as a
condition in CreateParams method to set the FormStyle property as I want. If
you are facing this situation, inform me and I will provide you with more
details.

Hope this helps
Vahan

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章