CreateFormControl(pParent: Object): Object;
pParent. The object that will owner of the created form.
The CreateFormControl method creates a new form and returns a context for managing this form.
As a value of the pParent parameter, one should send the object implemented by the IWin32Window interface. If the Null value is sent as a value, the created form will be equal to that, in which it was created. If the form is created from an application macro called by any repository object, use the IApplicationWindows.ForegroundWindow property to send the object window as a parent one.
To access parameters of the created form, one should cast the result of the CreateFormControl method to the IFormControl type.
To open the created form, set the Visible property to True. If the pParent parameter is specified, the created form is always displayed above the specified parent window. Parent window parameters are also available in the ParentWindow property.
The ShowModal method can also be used to open the form. And the form is open in a modal mode relatively to the specified parent window.
NOTE. If the Null value is passed as a value of the pParent parameter during form creation, and the ShowModal method is used to display the form, the form is opened in a modal mode relatively to the objects navigator.
Executing the example requires a form and a button named Button1 on it. The repository also contains a form with the TestForm identifier.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
MB: IMetabase;
f: IFormControl;
Begin
MB := MetabaseClass.Active;
f := (MB.ItemById("TestForm").Bind As IForm).CreateFormControl(Self) As IFormControl;
f.ShowModal;
End Sub Button1OnClick;
Clicking the button creates and displays the TestForm form. This form is opened in a modal mode relatively to the form, during which execution it was created.
See also: