Si quieres crear el Panel de forma dinámica puedes hacerlo así:
Código Delphi
[-]
type
TFMPruebas = class(TForm)
...
procedure PNLEjecutarNotepadResize(Sender: TObject);
private
fNotepadHandle : HWND;
...
public
...
end;
procedure TFMPruebas.BEjecutarNotepadClick(Sender: TObject);
var
Rec: TShellExecuteInfo;
Panel : TPanel;
const
AVerb = 'open';
AParams = '';
AFileName = 'Notepad.exe';
ADir = '';
begin
Panel := TPanel.Create(Self);
with Panel do
begin
Parent := TabSheet1;
Align := alClient;
OnResize := PNLEjecutarNotepadResize;
end;
FillChar(Rec, SizeOf(Rec), #0);
Rec.cbSize := SizeOf(Rec);
Rec.fMask := SEE_MASK_NOCLOSEPROCESS;
Rec.lpVerb := PChar( AVerb );
Rec.lpFile := PChar( AfileName );
Rec.lpParameters := PChar( AParams );
Rec.lpDirectory := PChar( Adir );
Rec.nShow := SW_HIDE;
ShellExecuteEx(@Rec);
WaitForInputIdle(Rec.hProcess, 5000);
fNotepadHandle := Windows.FindWindow( 'Notepad', nil );
Windows.SetParent( fNotepadHandle, Panel.Handle );
Windows.SetFocus( fNotepadHandle );
Resize;
ShowWindow(fNotepadHandle, SW_SHOW);
end;
procedure TFMPruebas.PNLEjecutarNotepadResize(Sender: TObject);
begin
if IsWindow(fNotepadHandle) then begin
SetWindowPos(fNotepadHandle, 0, 0, 0, TPanel(Sender).ClientWidth, TPanel(Sender).ClientHeight,
SWP_ASYNCWINDOWPOS);
end;
end;