procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage(IntToStr(TWinControl(Form1.FindChildControl('Panel1')).Handle)); ShowMessage(IntToStr(TWinControl(Form1.FindChildControl('Panel2')).Handle)); end; 感谢谷歌
Panel1和Panel2 是控件名,你不可能两个控件名一样吧
既然知道控件名,不直接panel1.Handle; panel2.Handle;就得到了?
如果两个panl是同一个窗口上的话 直接取Form的 ComponentCount for I := 0 to ComponentCount do begin if Component[i] Is TPanel then begin 第一个 break; end; end;窗口增加控件, 都保存在compents一个列表中, 先创建的在前面
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(IntToStr(TWinControl(Form1.FindChildControl('Panel1')).Handle));
ShowMessage(IntToStr(TWinControl(Form1.FindChildControl('Panel2')).Handle));
end;
感谢谷歌
既然知道控件名,不直接panel1.Handle;
panel2.Handle;就得到了?
直接取Form的 ComponentCount
for I := 0 to ComponentCount do
begin
if Component[i] Is TPanel then
begin
第一个
break;
end;
end;窗口增加控件, 都保存在compents一个列表中, 先创建的在前面