Delphi dynamically creates a form and locks the window Value

Source: Internet
Author: User

Var

TempForm: array of TForm2;

Procedure TForm1.Button2Click (Sender: TObject );

Var

I: Integer;

BNew: Boolean;

Begin

BNew: = True;

For I: = Low (TempForm) to High (TempForm) do

Begin

IF TempForm [I]. Caption = Trim (Edit1.Text) then

Begin

TempForm [I]. Show;

BNew: = False;

Exit;

End;

BNew: = True;

End;

IF bNew then

Begin

SetLength (TempForm, Length (TempForm) + 1); // Add a value to the data

TempForm [High (TempForm)]: = TForm2.Create (nil); // create a form

TempForm [High (TempForm)]. Caption: = Trim (Edit1.Text); // The Form Caption is assigned to a value to lock

Self. CheckListBox1.Items. Add (Trim (Edit1.Text ));

TempForm [High (TempForm)]. Show; // the maximum value of the array is the currently created form.

End;

End;

Procedure TForm1.Button3Click (Sender: TObject );

Var

I: integer;

BName: String;

Begin

For I: = 0 to CheckListBox1.Count-1 do

Begin

If CheckListBox1.Selected [I] then

BName: = CheckListBox1.Items. Strings [I];

End;

For I: = Low (TempForm) to high (TempForm) do

Begin

If TempForm [I]. Caption = bName then

Begin

TempForm [I]. Edit1.text: = Edit2.text;

End;

End;

End;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.