]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/contrib/iewin/wxactivex.cpp
Moved tools to be a Python package in wxPython.tools, added scripts to
[wxWidgets.git] / wxPython / contrib / iewin / wxactivex.cpp
index 575d2fae2bb40f228a02e05ecd6cd3ec868ab36f..ac6df87513b0063a5e6648e2e3705689871cc742 100644 (file)
@@ -207,7 +207,7 @@ wxActiveX::wxActiveX(wxWindow * parent, wxString progId, wxWindowID id,
 {
     m_bAmbientUserMode = true;
     m_docAdviseCookie = 0;
 {
     m_bAmbientUserMode = true;
     m_docAdviseCookie = 0;
-    CreateActiveX((LPOLESTR) wxConvUTF8.cMB2WC(progId).data());
+    CreateActiveX((LPOLESTR) (const wchar_t *) progId.wc_str(wxConvUTF8));
 }
 
 wxActiveX::~wxActiveX()
 }
 
 wxActiveX::~wxActiveX()
@@ -268,7 +268,17 @@ void wxActiveX::CreateActiveX(REFCLSID clsid)
        // Get IOleObject interface
        hret = m_oleObject.QueryInterface(IID_IOleObject, m_ActiveX); 
        wxASSERT(SUCCEEDED(hret));
        // Get IOleObject interface
        hret = m_oleObject.QueryInterface(IID_IOleObject, m_ActiveX); 
        wxASSERT(SUCCEEDED(hret));
-       // Get IOleInPlaceObject interface
+
+    // document advise
+    m_docAdviseCookie = 0;
+    hret = m_oleObject->Advise(adviseSink, &m_docAdviseCookie);
+    WXOLE_WARN(hret, "m_oleObject->Advise(adviseSink, &m_docAdviseCookie),\"Advise\")");
+    m_oleObject->SetHostNames(L"wxActiveXContainer", NULL);
+       OleSetContainedObject(m_oleObject, TRUE);
+    OleRun(m_oleObject);
+
+
+    // Get IOleInPlaceObject interface
        hret = m_oleInPlaceObject.QueryInterface(IID_IOleInPlaceObject, m_ActiveX);
        wxASSERT(SUCCEEDED(hret));
 
        hret = m_oleInPlaceObject.QueryInterface(IID_IOleInPlaceObject, m_ActiveX);
        wxASSERT(SUCCEEDED(hret));
 
@@ -292,13 +302,6 @@ void wxActiveX::CreateActiveX(REFCLSID clsid)
         WXOLE_WARN(hret, "CreateActiveX::pPersistStreamInit->InitNew()");
     };
 
         WXOLE_WARN(hret, "CreateActiveX::pPersistStreamInit->InitNew()");
     };
 
-    // document advise
-    m_docAdviseCookie = 0;
-    hret = m_oleObject->Advise(adviseSink, &m_docAdviseCookie);
-    WXOLE_WARN(hret, "m_oleObject->Advise(adviseSink, &m_docAdviseCookie),\"Advise\")");
-    m_oleObject->SetHostNames(L"wxActiveXContainer", NULL);
-       OleSetContainedObject(m_oleObject, TRUE);
-
     if (! (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST))
                m_oleObject->SetClientSite(m_clientSite);
 
     if (! (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST))
                m_oleObject->SetClientSite(m_clientSite);
 
@@ -312,22 +315,26 @@ void wxActiveX::CreateActiveX(REFCLSID clsid)
        posRect.bottom = h;
 
     m_oleObjectHWND = 0;
        posRect.bottom = h;
 
     m_oleObjectHWND = 0;
-       hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
-       WXOLE_WARN(hret, "m_oleInPlaceObject->GetWindow(&m_oleObjectHWND)");
-    if (SUCCEEDED(hret))
-           ::SetActiveWindow(m_oleObjectHWND);
+
+    if (m_oleInPlaceObject.Ok())
+    {
+       hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
+           WXOLE_WARN(hret, "m_oleInPlaceObject->GetWindow(&m_oleObjectHWND)");
+        if (SUCCEEDED(hret))
+               ::SetActiveWindow(m_oleObjectHWND);
+    };
 
 
     if (! (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME))
     {
 
 
     if (! (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME))
     {
-               if (w > 0 && h > 0)
+               if (w > 0 && h > 0 && m_oleInPlaceObject.Ok())
                        m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
 
                hret = m_oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, m_clientSite, 0, (HWND)GetHWND(), &posRect);
         hret = m_oleObject->DoVerb(OLEIVERB_SHOW, 0, m_clientSite, 0, (HWND)GetHWND(), &posRect);
     };
 
                        m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
 
                hret = m_oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, m_clientSite, 0, (HWND)GetHWND(), &posRect);
         hret = m_oleObject->DoVerb(OLEIVERB_SHOW, 0, m_clientSite, 0, (HWND)GetHWND(), &posRect);
     };
 
-       if (! m_oleObjectHWND)
+       if (! m_oleObjectHWND && m_oleInPlaceObject.Ok())
        {
                hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
                WXOLE_WARN(hret, "m_oleInPlaceObject->GetWindow(&m_oleObjectHWND)");
        {
                hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
                WXOLE_WARN(hret, "m_oleInPlaceObject->GetWindow(&m_oleObjectHWND)");
@@ -385,13 +392,14 @@ public:
 
 static ActiveXEventMapFlusher s_dummyActiveXEventMapFlusher;
 
 
 static ActiveXEventMapFlusher s_dummyActiveXEventMapFlusher;
 
-const wxEventType& RegisterActiveXEvent(wxString eventName)
+const wxEventType& RegisterActiveXEvent(wxChar *eventName)
 {
 {
-    ActiveXEventMap::iterator it = sg_eventMap.find(eventName);
+    wxString ev = eventName;
+    ActiveXEventMap::iterator it = sg_eventMap.find(ev);
     if (it == sg_eventMap.end())
     {
         wxEventType  *et = new wxEventType(wxNewEventType());
     if (it == sg_eventMap.end())
     {
         wxEventType  *et = new wxEventType(wxNewEventType());
-        sg_eventMap[eventName] = et;
+        sg_eventMap[ev] = et;
 
         return *et;
     };
 
         return *et;
     };
@@ -857,17 +865,21 @@ void wxActiveX::OnSize(wxSizeEvent& event)
        if (w <= 0 && h <= 0)
                return;
 
        if (w <= 0 && h <= 0)
                return;
 
-       if (m_oleInPlaceObject) 
+       if (m_oleInPlaceObject.Ok()
                m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
 
        // extents are in HIMETRIC units
                m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
 
        // extents are in HIMETRIC units
-    SIZEL sz = {w, h};
-       PixelsToHimetric(sz);
+    if (m_oleObject.Ok())
+    {
+        SIZEL sz = {w, h};
+           PixelsToHimetric(sz);
 
 
-    SIZEL sz2;
-    m_oleObject->GetExtent(DVASPECT_CONTENT, &sz2);
-    if (sz2.cx !=  sz.cx || sz.cy != sz2.cy)
-        m_oleObject->SetExtent(DVASPECT_CONTENT, &sz);
+        SIZEL sz2;
+
+        m_oleObject->GetExtent(DVASPECT_CONTENT, &sz2);
+        if (sz2.cx !=  sz.cx || sz.cy != sz2.cy)
+            m_oleObject->SetExtent(DVASPECT_CONTENT, &sz);
+    };
 }
 
 void wxActiveX::OnSetFocus(wxFocusEvent& event)
 }
 
 void wxActiveX::OnSetFocus(wxFocusEvent& event)