Thread View: borland.public.cppbuilder.nativeapi
1 messages
1 total messages
Started by Johann M�hlbauer
Fri, 17 Mar 2006 13:40
OpenOffice embedded in Form - WIndowPeer doesn't work
Author: 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;
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads