var AComp: TComponent; begin if Assigned (Label1) then begin Label1.Parent := Form2; AComp := Label1; RemoveComponent (AComp); Form2.InsertComponent (AComp); end end;
use two labels and set the propertis visible and caption
你设一个标志判断一下,在把二楼的代码改一下就成了。var BForm1:boolean;//判断LABEL在那个窗口上 TRUE FORM1上var AComp: TComponent; begin if BForm1 then if Assigned (Label1) then begin Label1.Parent := Form2; AComp := Label1; RemoveComponent (AComp); Form2.InsertComponent (AComp); end else if Assigned (Label1) then begin Label1.Parent := Form1; AComp := Label1; RemoveComponent (AComp); Form1.InsertComponent (AComp); end;
end;
你设一个标志判断一下,在把二楼的代码改一下就成了。var BForm1:boolean;//判断LABEL在那个窗口上 TRUE FORM1上var AComp: TComponent; begin if BForm1 then if Assigned (Label1) then begin Label1.Parent := Form2; AComp := Label1; RemoveComponent (AComp); Form2.InsertComponent (AComp); BForm1:=False; end else if Assigned (Label1) then begin Label1.Parent := Form1; AComp := Label1; RemoveComponent (AComp); Form1.InsertComponent (AComp); BForm1:=True; end;
說清楚一點....
AComp: TComponent;
begin
if Assigned (Label1) then
begin
Label1.Parent := Form2;
AComp := Label1;
RemoveComponent (AComp);
Form2.InsertComponent (AComp);
end
end;
我只能用一个label.
BForm1:boolean;//判断LABEL在那个窗口上 TRUE FORM1上var
AComp: TComponent;
begin
if BForm1 then
if Assigned (Label1) then
begin
Label1.Parent := Form2;
AComp := Label1;
RemoveComponent (AComp);
Form2.InsertComponent (AComp);
end
else
if Assigned (Label1) then
begin
Label1.Parent := Form1;
AComp := Label1;
RemoveComponent (AComp);
Form1.InsertComponent (AComp);
end;
end;
BForm1:boolean;//判断LABEL在那个窗口上 TRUE FORM1上var
AComp: TComponent;
begin
if BForm1 then
if Assigned (Label1) then
begin
Label1.Parent := Form2;
AComp := Label1;
RemoveComponent (AComp);
Form2.InsertComponent (AComp);
BForm1:=False;
end
else
if Assigned (Label1) then
begin
Label1.Parent := Form1;
AComp := Label1;
RemoveComponent (AComp);
Form1.InsertComponent (AComp);
BForm1:=True;
end;
end;