unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Vcl.Buttons,
Vcl.ComCtrls, Unit2;
type
TForm1 =
class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
ListView1: TListView;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
MyForm: TForm2;
implementation
{$R *.dfm}
function FindForm(H: THandle): TForm;
var
i: integer;
begin
Result :=
nil;
for i := 0
to Screen.FormCount -1
do begin
if Screen.Forms[i].Handle = H
then Result := Screen.Forms[i];
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
Li: TListItem;
begin
MyForm := TForm2.Create(
nil);
MyForm.Caption := inttostr(MyForm.Handle);
Li := Form1.ListView1.Items.Add;
Li.Caption := inttostr(MyForm.Handle);
MyForm.Show;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
myform := TForm2(FindForm(strtoint(listview1.Selected.Caption)));
myform.Label1.Caption := '
Hallo Welt';
end;
end.