读取delphi的.dfm文件,生成对应.pas的对象列表

procedure TFmInDBEdit.toprocobject(var file1:String;var TS1:TStrings);
var
cout,I:Integer;
TS2:TStrings;
temps,S1:string;

begin

TS2:=TStringList.Create;
TS2.LoadFromFile(file1);
TS1.Clear;
try
 //cout:=Pos('object',TS2[0]);//如果是TForm的子类,将其换成TForm类
// if cout=1 then
 begin
//  i:=pos(':',TS[0]);
//  temps:=Copy(TS[0],i+1,length(TS[0])-i);

// showmessage(temps);
for I := 1 to TS2.Count-1 do
begin
temps:=trim(TS2[i]);
cout:=Pos(‘object’,temps);
if cout=1 then
begin
S1:=copy(temps,7,length(temps)-6);
TS1.Add(S1+‘;’);
end;
end;
end;

finally

  TS2.Free;
end;

end;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 示例:SetParent(hwndChild,hwndNewParent),这个函数可以将窗口句柄hwndChild的父窗口设置为hwndNewParent。例如,可以使用SetParent(hChildWnd,hParentWnd)来将hChildWnd的父窗口设置为hParentWnd。 ### 回答2: Delphi XE5中的WinApi.Windows.SetParent函数用于将一个子控件的父控件更改为另一个控件。其用法如下: ``` WinApi.Windows.SetParent(ChildHandle: HWND; NewParentHandle: HWND): HWND; ``` 其中,ChildHandle是要更改父控件的子控件的句柄,NewParentHandle是要设置为子控件的新父控件的句柄。 例如,我们有一个主窗口Form1,上面有一个按钮Button1,以及一个容器Panel1。现在我们想将按钮Button1从主窗口Form1移动到容器Panel1中,可以使用SetParent函数来实现: ``` // 获取Button1和Panel1的句柄 var ButtonHandle: HWND; PanelHandle: HWND; begin ButtonHandle := Button1.Handle; PanelHandle := Panel1.Handle; // 将Button1的父控件更改为Panel1 WinApi.Windows.SetParent(ButtonHandle, PanelHandle); end; ``` 在上述代码中,我们使用Button1.Handle获取按钮Button1的句柄,使用Panel1.Handle获取容器Panel1的句柄。然后,通过调用SetParent函数将Button1的父控件更改为Panel1。这样,按钮Button1将移动到容器Panel1中。 需要注意的是,使用SetParent函数更改父控件后,原父控件不再拥有被移动的子控件的所有权。因此,在使用SetParent函数时,需要特别注意确保所操纵的窗口句柄的有效性和正确性。 ### 回答3: delphi XE5中的WinApi.Windows.SetParent函数可用于将一个控件的父级窗口设置为另一个窗口。使用该函数可以改变控件的父级窗口,将其移动到不同的容器中或者从一个容器中移除。 下面是一个使用delphi XE5的WinApi.Windows.SetParent函数的示例: ```delphi unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var Button1InAnotherForm: TButton; AnotherForm: TForm; begin // 创建一个新的窗口 AnotherForm := TForm.Create(nil); AnotherForm.Caption := '另一个窗口'; // 创建一个按钮并将其父级窗口设置为AnotherForm Button1InAnotherForm := TButton.Create(AnotherForm); Button1InAnotherForm.Parent := AnotherForm; Button1InAnotherForm.Left := 10; Button1InAnotherForm.Top := 10; Button1InAnotherForm.Caption := '另一个窗口上的按钮'; // 将AnotherForm显示出来 AnotherForm.Show; end; procedure TForm1.Button2Click(Sender: TObject); var Button1InAnotherForm: TButton; AnotherForm: TForm; begin // 创建一个新的窗口 AnotherForm := TForm.Create(nil); AnotherForm.Caption := '另一个窗口'; // 创建一个按钮并将其父级窗口设置为AnotherForm Button1InAnotherForm := TButton.Create(AnotherForm); Button1InAnotherForm.Parent := AnotherForm; Button1InAnotherForm.Left := 10; Button1InAnotherForm.Top := 10; Button1InAnotherForm.Caption := '另一个窗口上的按钮'; // 将Button1InAnotherForm的父级窗口设置为Form1 WinApi.Windows.SetParent(Button1InAnotherForm.Handle, Form1.Handle); end; end. ``` 在上面的示例中,单击Button1会创建一个新的窗口AnotherForm,并在该窗口上显示一个按钮Button1InAnotherForm。而单击Button2会创建同样的新窗口AnotherForm,并在该窗口上显示一个按钮Button1InAnotherForm,然后使用WinApi.Windows.SetParent函数将Button1InAnotherForm的父级窗口设置为Form1,从而将按钮从AnotherForm移动到Form1上显示。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值