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.It is possible. (for Windows OS at least)
However, you can start the application and comunicate with it - see http://wiki.freepascal.org/Executing_External_Programs#TProcess
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) 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)But my guess its not work on linux only windows. True ?Well, Windows.SetParent is, of course, a Windows API call.
Even it works with Notepad for example, some other applications seem not be able to be catched.Could be that that application creates multiple windows of which you only catch the (hidden) main one. Hard to tell without knowing the application.
Someone here who can explain me why this could be possible?
How did you get the classname?Like I said earlier, with a Windows spy program.
Hmm, it seem that all Lazarus Programs have "Window" as class name, is there a (easy) way to change that for the own program?Yes, Lazarus always uses "Window" as Class Name
And regarding the Winbox i got fucked up because when it's connecting to a device it opens a completely new window which then appears outside of the application with the panel...Yeah, it's hard to contain program's that do that.