If I understand what you want, you expect your panel to behave like desktop enviroment and host a graphical application? I do not believe that it is possible.
However, you can start the application and comunicate with it - see http://wiki.freepascal.org/Executing_External_Programs#TProcess
It is possible. (for Windows OS at least)
Look at the following video:
https://www.youtube.com/watch?v=N6GWgxEvibEYou just have to use SetParent to attach the window-handle to another control.
You can also find an example here:
http://www.lazarusforum.de/viewtopic.php?f=10&t=3256I tried to create an example. The only problem I had was getting the correct handle from the Calculator-window. It seems the handle TProcess returns is not the correct one. So I had to do FindWindow to find the window with the title Calculator and attach that to the panel.
uses Process, Windows;
// https://www.youtube.com/watch?v=N6GWgxEvibE
// http://www.lazarusforum.de/viewtopic.php?f=10&t=3256
procedure TForm1.Button1Click(Sender: TObject);
function FindWindowByTitle(WindowTitle: string): Hwnd;
var
NextHandle: Hwnd;
NextTitle: array[0..260] of char;
begin
// Get the first window
NextHandle := GetWindow(Application.Mainform.Handle, GW_HWNDFIRST);
while NextHandle > 0 do
begin
// retrieve its text
GetWindowText(NextHandle, NextTitle, 255);
if Pos(WindowTitle, StrPas(NextTitle)) <> 0 then
begin
Result := NextHandle;
Exit;
end
else
// Get the next window
NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
end;
Result := 0;
end;
procedure Attach2Control(aWnd: Hwnd; aControl: TWinControl);
var
WPM: WINDOWPLACEMENT;
begin
Windows.SetParent(aWnd, aControl.Handle);
SetWindowLong(aWnd, GWL_STYLE, GetWindowLong(aWnd, GWL_STYLE) and not WS_CAPTION);
WPM.Length := SizeOf(WPM);
GetWindowPlacement(aWnd, @WPM);
WPM.ShowCmd := SW_ShowMaximized;
WPM.rcNormalPosition := Classes.Rect(0, 0, aControl.Width, aControl.Height);
SetWindowPlacement(aWnd, @WPM);
end;
var
xWnd: HWND;
aProcess: TProcess;
begin
aProcess := TProcess.Create(nil);
aProcess.CommandLine := 'calc.exe';
aProcess.Options := aProcess.Options - [poWaitOnExit];
aProcess.Execute;
Sleep(100);
xWnd := FindWindowByTitle('Calculator');
Attach2Control(xWnd, Panel1);
aProcess.Free;
end;
(screenshot attached)
If you leave the windowplacement and SetWindowLong lines out, and just only leave the SetParent-line you can even keep the title-bar as in screenshot #2.
Windows.SetParent(aWnd, aControl.Handle);
//SetWindowLong(aWnd, GWL_STYLE, GetWindowLong(aWnd, GWL_STYLE) and not WS_CAPTION);
//WPM.Length := SizeOf(WPM);
//GetWindowPlacement(aWnd, @WPM);
//WPM.ShowCmd := SW_ShowMaximized;
//WPM.rcNormalPosition := Classes.Rect(0, 0, aControl.Width, aControl.Height);
//SetWindowPlacement(aWnd, @WPM);
(But then it could be that your application is "out of sight" so you need to maximize your panel to see it and drag it back in sight)