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
本文介绍了一种在Delphi中解决MDI子窗体作为模态对话框显示的问题的方法。通过设置不同祖先窗体的形式样式和可见性属性,并利用全局变量控制同一窗体在不同场景下作为模态或非模态窗口显示。
4011

被折叠的 条评论
为什么被折叠?



