小弟佩服谁能将
string类型(widestring )转换为object类型(twincontrol)
不可能吧?除非.....
function TForm1.getwincontrol(s: string): Twincontrol;
begin
result:= (Form1.FindComponent(s) as Twincontrol);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage( ( getwincontrol('edit1') as Tedit).text);
end;
还有这一段,在应用程序中可执行,但在dll里面就老出错,急得我……8<
procedure TForm1.abcPopupMenu1MenuCommand(Sender: TObject);
with Sender as TMenuItemdo
begin
Imna:=Caption;
strimename:=imna;
procedure TForm2.Button1Click(Sender: TObject);
var
i: Integer;
begin
//这两种方法的效果是一样的。通过RTTI来实现。所有没有创建的
//Form不能找到
for i := 0 to Screen.FormCount - 1do
begin
ListBox1.Items.Add(Screen.Forms.Name);
end;
for i := 0 to Application.ComponentCount - 1do
if Application.Components is TForm then
ListBox1.Items.Add(TForm(Application.Components).Name);
end;