unit Unit12;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
H: THandle;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ShellExecute(Handle,PChar('Open'),PChar('Notepad.exe'),'','',SW_SHOWNORMAL);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
H := FindWindow(nil, '无标题 - 记事本');
if H <> 0 then
begin
Windows.SetParent(H, Panel1.Handle);
Windows.SetWindowPos(h, 0, 0, 0, Panel1.Width, Panel1.Height, 0);
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Windows.SetParent(H, 0);
end;
end.