var
Word, Excel: hWnd;
Thread, WordThread, ExcelThread:
Handle;
begin
// Fenster suchen
Word := FindWindow(
nil,'
Fenstertext');
Excel := FindWindow(
nil,'
Fenstertext');
// Parent setzen
SetParent(Word, Form1.Handle);
SetParent(Excel, Form1.Handle);
// Threads suchen
Thread := GetCurrentThreadID;
WordThread := GetWindowThreadProcessId(Word,
nil);
ExcelThread := GetWindowThreadProcessId(Excel,
nil);
// Input verknüpfen
AttachThreadInput(Thread,WordThread,true);
AttachThreadInput(Thread,ExcelThread,true);
// Fenster verschieben / Größe setzen
MoveWindow(Word,0,0,500,500);
MoveWindow(Excel,500,0,500,500);
// Child-Style setzen
SetWindowLong(Word,GWL_STYLE,GetWindowLong(Word,GWL_STYLE)
or WS_CHILD);
SetWindowLong(Excel,GWL_STYLE,GetWindowLong(Excel,GWL_STYLE)
or WS_CHILD);
end;