unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ShellAPI;
type
TForm1 =
class(TForm)
Panel1: TPanel;
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
aWnd: hWnd;
//Handle auf das Window welches man einsperren möchte
FResized: Boolean;
FMaximized: Boolean;
procedure WMSIZE(
Var AMsg:TWMSize);
message WM_SIZE;
procedure WMEXITSIZEMOVE(
Var AMsg:TMessage);
message WM_EXITSIZEMOVE;
procedure FormResized;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormActivate(Sender: TObject);
var
AppName, AppExe : PAnsiChar;
begin
AppName := '
notepad';
AppExe := '
notepad.exe';
//ext. Anwendung aufrufen...
ShellExecute(0, '
open', AppExe,
nil,
nil, SW_HIDE);
// fremde Anwendung in eigene Anwendung kappseln
aWnd := FindWindow(AppName,
nil);
while aWnd = 0
do aWnd := FindWindow(AppName,
nil);
//Solange warten bis Programm gestartet wurde
Windows.SetParent(aWnd, Panel1.Handle);
// SetWindowLong(aWnd,GWL_STYLE,GetWindowLong(aWnd,GWL_STYLE) and not WS_CAPTION); // Titelleiste ausblenden
ShowWindow(aWnd, SW_MAXIMIZE);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FResized := false;
FMaximized := (WindowState = wsMaximized);
end;
procedure TForm1.WMSIZE(
var AMsg: TWMSize);
begin
inherited;
if (AMsg.SizeType = SIZE_RESTORED)
and FMaximized
then
begin
FormResized;
FMaximized := false;
end;
if (AMsg.SizeType=SIZE_MAXIMIZED)
then
begin
FormResized;
FMaximized := true;
end;
end;
procedure TForm1.WMEXITSIZEMOVE(
var AMsg: TMessage);
begin
inherited;
FormResized;
end;
procedure TForm1.FormResized;
begin
ShowWindow(aWnd, SW_HIDE);
ShowWindow(aWnd, SW_MAXIMIZE);
end;
end.