Article View: borland.public.cppbuilder.nativeapi
Article #4116OpenOffice embedded in Form - WIndowPeer doesn't work
From: Johann M�hlbauer
Date: Fri, 17 Mar 2006 13:40
Date: Fri, 17 Mar 2006 13:40
157 lines
6246 bytes
6246 bytes
OpenOffice embedded in Form - WIndowPeer doesn't work
Hi,
I'm trying to embedd OpenOffice into a Form.
All things work fine, the frame is visible and the loaded document too.
But the frame is (created) on desktop.
Obviously the frame don't use the user-created WindowPeer.
I hope someone can help. Thanks in advance.
bye,
j.muehlbauer
HRESULT __fastcall
TForm1::COM_SUN_STAR_WINDOWDESCRIPTOR_CREATE(CComPtr<IDispatch>&
pDispFactory,
CComPtr<IDispatch>& pDispWindowDescriptor, int Type /*WindowStyle*/,
OLECHAR* WindowServiceName,
CComQIPtr<IDispatch, &IID_IDispatch>& pDispParent, short ParentIndex,
CComPtr<IDispatch>& pDispRectangle,
long WindowAttributes)
{
// create WindowDescriptor structure
HRESULT hr = GetUnoStruct( pDispFactory,
L"com.sun.star.awt.WindowDescriptor", pDispWindowDescriptor );
if( !SUCCEEDED( hr ) ) return hr;
// fill in descriptor with info
OLECHAR* sDescriptorMemberNames[] =
{
L"Bounds",
L"Type",
L"ParentIndex",
L"WindowAttributes",
L"Parent"
// L"WindowServiceName" ===> error
};
CComVariant pDescriptorVar[5];
pDescriptorVar[0] = CComVariant( pDispRectangle );
pDescriptorVar[1] = CComVariant( Type );
pDescriptorVar[2] = CComVariant( ParentIndex );
pDescriptorVar[3] = CComVariant( WindowAttributes );
pDescriptorVar[4] = CComVariant( pDispParent );
// pDescriptorVar[5] = CComVariant( WindowServiceName ); ===> error
hr = PutPropertiesToIDisp( pDispWindowDescriptor, sDescriptorMemberNames,
pDescriptorVar, 5 );
return hr;
}
// ---------------------------------------------------------------------------
HRESULT __fastcall TForm1::CreateFrame( HWND hwnd, RECT rcBounds )
{
if( m_spDispDesktop )
return S_OK;
HRESULT hr;
// create XToolkit instance
CComPtr<IDispatch> pdispToolkit;
hr = GetIDispByFunc( m_spDispFactory, L"createInstance", &CComVariant(
L"com.sun.star.awt.Toolkit" ), 1, pdispToolkit );
if( !SUCCEEDED(hr) ) return hr;
// create rectangle structure
CComPtr<IDispatch> pdispRectangle;
hr = COM_STAR_AWT_RECTANGLE(m_spDispFactory, rcBounds, pdispRectangle);
if( !SUCCEEDED(hr) ) return hr;
// create frame
hr = GetIDispByFunc( m_spDispFactory, L"createInstance",
&CComVariant(L"com.sun.star.frame.Task"), 1, m_spDispFrame );
if( !SUCCEEDED(hr) || !m_spDispFrame )
hr = GetIDispByFunc( m_spDispFactory, L"createInstance",
&CComVariant(L"com.sun.star.frame.Frame"), 1, m_spDispFrame );
if( !SUCCEEDED(hr) ) return hr;
// interface XSystemChildFactory -
com/sun/star/awt/XSystemChildFactory.html#createSystemChild
CComPtr< CComObject<TWindowPeer2> > pPeerToSend = new
CComObject<TWindowPeer2>();
pPeerToSend->FinalConstruct();
pPeerToSend->SetWindowHandle(hwnd);
CComQIPtr< IDispatch, &IID_IDispatch > pIDispToSend( pPeerToSend );
int WindowStyle = WC_TOP; //= 0; WC_TOP WC_MODALTOP WC_CONTAINER
WC_SIMPLE
short ParentIndex = 1;
long WindowAttributes = WA_SHOW/*|WA_SYSTEMDEPENDENT*/;// =33
WA_SIZEABLE|WA_SHOW|WA_SYSTEMDEPENDENT;
CComPtr<IDispatch> pdispWinDescr;
hr = COM_SUN_STAR_WINDOWDESCRIPTOR_CREATE( m_spDispFactory,
pdispWinDescr,
WindowStyle,
L"WorkerWindow",
pIDispToSend,
ParentIndex,
pdispRectangle,
WindowAttributes );
if( !SUCCEEDED(hr) ) return hr;
// create window with toolkit
hr = GetIDispByFunc( pdispToolkit, L"createWindow",
&CComVariant(pdispWinDescr), 1, m_spDispWindow );
if( !SUCCEEDED(hr) ) return hr;
// initialize frame
CComVariant dummyResult;
hr = ExecuteFunc( m_spDispFrame, L"initialize",
&CComVariant(m_spDispWindow), 1, &dummyResult );
if( !SUCCEEDED(hr) )
{
ShowMessage("Fehler beim [initialize frame]");
return hr;
}
// create desktop
hr = GetIDispByFunc( m_spDispFactory, L"createInstance", &CComVariant(
L"com.sun.star.frame.Desktop" ), 1, m_spDispDesktop );
if( !SUCCEEDED(hr) ) return hr;
// set some properties to the layout manager, ignore errors for now
SetLayoutManagerProps(m_spDispFrame);
// create tree of frames
CComPtr<IDispatch> pdispChildren;
hr = GetIDispByFunc( m_spDispDesktop, L"getFrames", NULL, 0,
pdispChildren );
// hr = GetIDispByFunc( m_spDispFrame, L"getActiveFrame", NULL, 0,
pdispChildren );
if( !SUCCEEDED(hr) ) return hr;
// insert new frame into desktop hierarchy
hr = ExecuteFunc( pdispChildren, L"append", &CComVariant(m_spDispFrame),
1, &dummyResult );
if( !SUCCEEDED(hr) ) return hr;
// initialize window
hr = ExecuteFunc( m_spDispWindow, L"setBackground",
&CComVariant((long)0x4FFFFFFF), 1, &dummyResult );
if( !SUCCEEDED(hr) ) return hr;
hr = ExecuteFunc( m_spDispWindow, L"setVisible", &CComVariant(TRUE), 1,
&dummyResult );
if( !SUCCEEDED(hr) ) return hr;
// position of openoffice-window
hr = SetPosSize(m_spDispWindow, rcBounds);
if( !SUCCEEDED(hr) ) return hr;
return hr;
}
Technical Details
Message-ID:
<441abc04$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,5f0b8c817d0cfc89,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Johann M�hlbauer" <dm.2000@web.de> Newsgroups: borland.public.cppbuilder.nativeapi Subject: OpenOffice embedded in Form - WIndowPeer doesn't work Date: Fri, 17 Mar 2006 14:40:16 +0100 Lines: 159 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 NNTP-Posting-Host: 84.146.100.44 Message-ID: <441abc04$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1142602756 84.146.100.44 (17 Mar 2006 05:39:16 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail