<[email protected]>Hi
We embed a writer instance inside a Delphi form. When another, external
open-office document is opened inside a separate instance of Writer, and
that window is closed, then our embedded instance is also closed. If two
External writer documents are opened in separate windows, closing one of
them does not close the other one. That is what we want also with ours.
It seems like the last instance of Writer kills the global Desktop instance
if it thinks that it is the last instance. Also, each instance of Writer
has all the other instances listed inside its "Window" menu, but our
embedded instance doesn't show there.
Below is the routine that does the embedding into a group box; what are we
doing wrong? I have a feeling it somehow has to do with us "registering"
with the global Desktop instance that we are currently connected.
****************************************************************************************************************************************
procedure TfAnchorWindow.LoadDocumentFromFile(const AFileName: UTF8;
AMergeFields: Boolean);
var
LOOHandle: HWND;
LAwtToolkit, LWindowDesc, LWindowPeer, LFrame, LArgs: Variant;
begin
{We check to see if any other instances of OpenOffice are open, and close
them}
if not VarIsNull(FOpenOfficeWriter.FDocument) then
begin
FOpenOfficeWriter.FDocument.Close(True);
FOpenOfficeWriter.FDocument := Null;
end;
{Make the Connection to OpenOffice}
ConnectOpenOffice;
{Create our own frame for OpenOffice}
LAwtToolkit := CreateUnoService('com.sun.star.awt.Toolkit');
LWindowDesc := CreateUnoStruct('com.sun.star.awt.WindowDescriptor');
LWindowDesc.Type := 0;
LWindowDesc.WindowServiceName := 'workwindow';
LWindowDesc.ParentIndex := -1;
LWindowDesc.WindowAttributes := 0;
LWindowPeer := LAwtToolkit.createWindow(LWindowDesc);
LOOHandle := LWindowPeer.getWindowHandle(dummyArray, 1);
FOOHandle := LOOHandle;
LFrame := CreateUnoService('com.sun.star.frame.Frame');
LFrame.initialize(LWindowPeer);
LFrame.setCreator(StarDesktop);
{We need to create the window invisible, to avoid a bug in OpenOffice
where a stray line appears on the
screen}
LArgs := VarArrayCreate([0, 0], varVariant);
LArgs[0] := MakePropertyValue(AnsiString('Hidden'), true);
FOpenOfficeWriter.FDocument := MakeDocument(LFrame, AFileName, LArgs);
if AMergeFields then
PerformDocumentFieldSubstitution;
{We use the MSDN functions to embed our frameless OpenOffice inside our
own groupbox}
Windows.SetParent(LOOHandle, gbOODeanchored.Handle);
ResetOpenOfficeWindow(FOOHandle);
FOpenOfficeWriter.FDocument.getCurrentController.Frame.getContainerWindow.setVisible(True);
end;
****************************************************************************************************************************************
kind regards
Caleb Hattingh