mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
now delaying initializing the plugin untill ActiveX control is ready to draw it
This commit is contained in:
parent
4df192c752
commit
1ac436a01f
@ -187,6 +187,11 @@ void CP3DActiveXCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInv
|
||||
if (!pdc)
|
||||
return;
|
||||
|
||||
if ( !m_instance.IsInit( ) )
|
||||
{
|
||||
Init( );
|
||||
}
|
||||
|
||||
CBrush brBackGnd(TranslateColor(AmbientBackColor()));
|
||||
pdc->FillRect(rcBounds, &brBackGnd);
|
||||
|
||||
@ -348,17 +353,6 @@ int CP3DActiveXCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
}
|
||||
}
|
||||
}
|
||||
std::string p3dDllFilename;
|
||||
error = m_instance.DownloadP3DComponents( p3dDllFilename );
|
||||
if ( !error && !( p3dDllFilename.empty() ) )
|
||||
{
|
||||
error = m_instance.LoadPlugin( p3dDllFilename );
|
||||
if ( !error )
|
||||
{
|
||||
m_pPandaObject = new PPandaObject( this, NULL );
|
||||
m_instance.Start( m_instance.GetP3DFilename( ) );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -369,7 +363,26 @@ LRESULT CP3DActiveXCtrl::OnPandaNotification(WPARAM wParam, LPARAM lParam)
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT CP3DActiveXCtrl::ExchangeProperties(CPropExchange* pPX)
|
||||
int CP3DActiveXCtrl::Init( )
|
||||
{
|
||||
int error( 0 );
|
||||
std::string p3dDllFilename;
|
||||
|
||||
error = m_instance.DownloadP3DComponents( p3dDllFilename );
|
||||
if ( !error && !( p3dDllFilename.empty() ) )
|
||||
{
|
||||
error = m_instance.LoadPlugin( p3dDllFilename );
|
||||
if ( !error )
|
||||
{
|
||||
m_pPandaObject = new PPandaObject( this, NULL );
|
||||
m_instance.Start( m_instance.GetP3DFilename( ) );
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CP3DActiveXCtrl::ExchangeProperties( CPropExchange* pPX )
|
||||
{
|
||||
USES_CONVERSION;
|
||||
HRESULT hr = E_FAIL;
|
||||
|
@ -74,6 +74,7 @@ public:
|
||||
};
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
|
||||
int Init( );
|
||||
virtual P3D_object* GetP3DObject( );
|
||||
virtual IOleClientSite* GetClientSte();
|
||||
|
||||
|
@ -90,7 +90,7 @@ void P3D_NofificationSync(P3D_instance *instance)
|
||||
}
|
||||
|
||||
PPInstance::PPInstance( CP3DActiveXCtrl& parentCtrl ) :
|
||||
m_parentCtrl( parentCtrl ), m_p3dInstance( NULL ), m_p3dObject( NULL ), m_handleRequestOnUIThread( true )
|
||||
m_parentCtrl( parentCtrl ), m_p3dInstance( NULL ), m_p3dObject( NULL ), m_handleRequestOnUIThread( true ), m_isInit( false )
|
||||
{
|
||||
TCHAR tempFolderName[ MAX_PATH ];
|
||||
DWORD pathLength = ::GetTempPath( MAX_PATH, tempFolderName );
|
||||
@ -306,6 +306,7 @@ int PPInstance::UnloadPlugin()
|
||||
{
|
||||
nout << "Finalizing P3D\n";
|
||||
P3D_finalize();
|
||||
m_isInit = false;
|
||||
|
||||
nout << "Unloading P3D dll " << s_hP3DPluginDll << "\n";
|
||||
if ( !::FreeLibrary( s_hP3DPluginDll ) )
|
||||
@ -355,7 +356,7 @@ int PPInstance::Start( const std::string& p3dFilename )
|
||||
if ( !m_p3dInstance )
|
||||
{
|
||||
nout << "Error creating P3D instance: " << GetLastError() << "\n";
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
CComPtr<IDispatch> pDispatch;
|
||||
PPBrowserObject *pobj = new PPBrowserObject( &m_parentCtrl, pDispatch );
|
||||
@ -374,10 +375,13 @@ int PPInstance::Start( const std::string& p3dFilename )
|
||||
|
||||
if ( !P3D_instance_start( m_p3dInstance, false, p3dRemoteFilename.c_str() ) )
|
||||
{
|
||||
nout << "Error starting P3D instance: " << GetLastError() << "\n";
|
||||
nout << "Error starting P3D instance: " << GetLastError() << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
m_isInit = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string PPInstance::GetHostUrl( )
|
||||
|
@ -55,8 +55,11 @@ public:
|
||||
|
||||
static void HandleRequestLoop();
|
||||
|
||||
inline bool IsInit() { return m_isInit; }
|
||||
|
||||
HWND m_parentWnd;
|
||||
CEvent m_eventStop;
|
||||
|
||||
P3D_object* m_p3dObject;
|
||||
|
||||
protected:
|
||||
@ -74,4 +77,5 @@ protected:
|
||||
PPLogger m_logger;
|
||||
|
||||
bool m_handleRequestOnUIThread;
|
||||
bool m_isInit;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user