Standard Writing of Some Codes of FORM

xiaoxiao2021-03-06  42

Create an Form

Create an instance of a form: someform: = tsomeform.create (application);

Not to use: Tapplication.createform (Tsomeform, Someform);

Because Tapplication.createForm () checks whether the mainform is nil, if yes, the newly created form is used as the master Form.

Open a mode Form

Open a standard form of formal form:

Modalform: = TMODALFORM.CREATE (Application);

Try

if MODALFORM.SHOWMODAL = MROK THEN

{do something}

Finally

Modalform.free;

END;

Open a non-mode FORM

Open a standard way to do not mode Form is:

Someform: = Tsomeform.create (Application);

Someform.show;

And release this form in the ONCLOSE event in Form:

Procedure Tsomeform.FormClose (Sender: TpoBject; VAR Action: Tclosection);

Begin

Action: = CAFREE;

END;

A plurality of instances that prevent an FORM

If not assigned (someform) THEN / / can also be written as if someform = nil dam

Someform: = Tsomeform.create (Application);

Someform.show;

And release this form in the ONCLOSE event in Form:

Procedure Tsomeform.FormClose (Sender: TpoBject; VAR Action: Tclosection);

Begin

Action: = CAFREE;

END;

At the same time, this FORM variable is set to NIL in the ONDESTROY event in Form:

Procedure TfrmMaterial.FormDestroy (Sender: TOBJECT);

Begin

Someform: = NIL;

END;

转载请注明原文地址:https://www.9cbs.com/read-71027.html

New Post(0)