]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/contrib/activex/wxie/wxactivex.cpp
don't draw focus rect for custom drawn items when the list control doesn't have focus
[wxWidgets.git] / wxPython / contrib / activex / wxie / wxactivex.cpp
index 46f372c9ee4f8738e1ea644bf4866eb1cf954038..77d372d9937b86158cd923b12834926c681bf28a 100644 (file)
@@ -255,7 +255,6 @@ wxWindow(parent, id, pos, size, style, name)
     m_bAmbientUserMode = true;
     m_docAdviseCookie = 0;
     CreateActiveX(clsid);
     m_bAmbientUserMode = true;
     m_docAdviseCookie = 0;
     CreateActiveX(clsid);
-    m_bestSize = GetSize();
 }
 
 wxActiveX::wxActiveX(wxWindow * parent, const wxString& progId, wxWindowID id,
 }
 
 wxActiveX::wxActiveX(wxWindow * parent, const wxString& progId, wxWindowID id,
@@ -268,7 +267,6 @@ wxActiveX::wxActiveX(wxWindow * parent, const wxString& progId, wxWindowID id,
     m_bAmbientUserMode = true;
     m_docAdviseCookie = 0;
     CreateActiveX((LPOLESTR) (const wchar_t *) progId.wc_str(wxConvUTF8));
     m_bAmbientUserMode = true;
     m_docAdviseCookie = 0;
     CreateActiveX((LPOLESTR) (const wchar_t *) progId.wc_str(wxConvUTF8));
-    m_bestSize = GetSize();
 }
 
 wxActiveX::~wxActiveX()
 }
 
 wxActiveX::~wxActiveX()
@@ -300,12 +298,13 @@ wxActiveX::~wxActiveX()
         m_oleObject->Close(OLECLOSE_NOSAVE);
         m_oleObject->SetClientSite(NULL);
     }
         m_oleObject->Close(OLECLOSE_NOSAVE);
         m_oleObject->SetClientSite(NULL);
     }
+
+    // Unregister object as active
+    RevokeActiveObject(m_pdwRegister, NULL);
 }
 
 void wxActiveX::CreateActiveX(REFCLSID clsid)
 {
 }
 
 void wxActiveX::CreateActiveX(REFCLSID clsid)
 {
-    SetTransparent();
-
     HRESULT hret;
 
     ////////////////////////////////////////////////////////
     HRESULT hret;
 
     ////////////////////////////////////////////////////////
@@ -319,10 +318,15 @@ void wxActiveX::CreateActiveX(REFCLSID clsid)
     wxCHECK_RET(adviseSink.Ok(), _T("adviseSink not Ok"));
 
 
     wxCHECK_RET(adviseSink.Ok(), _T("adviseSink not Ok"));
 
 
-    // // Create Object, get IUnknown interface
+    // Create Object, get IUnknown interface
     m_ActiveX.CreateInstance(clsid, IID_IUnknown);
     wxCHECK_RET(m_ActiveX.Ok(), _T("m_ActiveX.CreateInstance failed"));
 
     m_ActiveX.CreateInstance(clsid, IID_IUnknown);
     wxCHECK_RET(m_ActiveX.Ok(), _T("m_ActiveX.CreateInstance failed"));
 
+    // Register object as active
+    unsigned long pdwRegister;
+    hret = RegisterActiveObject(m_ActiveX, clsid, ACTIVEOBJECT_WEAK, &m_pdwRegister);
+    WXOLE_WARN(hret, "Unable to register object as active");
+
     // Get Dispatch interface
     hret = m_Dispatch.QueryInterface(IID_IDispatch, m_ActiveX); 
     WXOLE_WARN(hret, "Unable to get dispatch interface");
     // Get Dispatch interface
     hret = m_Dispatch.QueryInterface(IID_IDispatch, m_ActiveX); 
     WXOLE_WARN(hret, "Unable to get dispatch interface");
@@ -417,7 +421,7 @@ void wxActiveX::CreateActiveX(REFCLSID clsid)
         // Update by GBR to resize older controls
         wxSizeEvent szEvent;
         szEvent.m_size = wxSize(w, h) ;
         // Update by GBR to resize older controls
         wxSizeEvent szEvent;
         szEvent.m_size = wxSize(w, h) ;
-        AddPendingEvent(szEvent);
+        GetEventHandler()->AddPendingEvent(szEvent);
     };
 }
 
     };
 }
 
@@ -895,7 +899,7 @@ public:
         {
             // cdecl call
             // sometimes the pDispParams does not match the param info for a activex control
         {
             // cdecl call
             // sometimes the pDispParams does not match the param info for a activex control
-            int nArg = min(func.params.size(), pDispParams->cArgs);
+            int nArg = wxMin(func.params.size(), pDispParams->cArgs);
             for (int i = nArg - 1; i >= 0; i--)
             {
                 VARIANTARG& va = pDispParams->rgvarg[i];
             for (int i = nArg - 1; i >= 0; i--)
             {
                 VARIANTARG& va = pDispParams->rgvarg[i];
@@ -910,8 +914,8 @@ public:
 
         if (func.hasOut)
         {
 
         if (func.hasOut)
         {
-            int nArg = min(func.params.size(), pDispParams->cArgs);
-            m_activeX->GetParent()->ProcessEvent(event);
+            int nArg = wxMin(func.params.size(), pDispParams->cArgs);
+            m_activeX->GetEventHandler()->ProcessEvent(event);
             for (int i = 0; i < nArg; i++)
             {
                 VARIANTARG& va = pDispParams->rgvarg[i];
             for (int i = 0; i < nArg; i++)
             {
                 VARIANTARG& va = pDispParams->rgvarg[i];
@@ -926,7 +930,7 @@ public:
             };
         }
         else
             };
         }
         else
-            m_activeX->GetParent()->AddPendingEvent(event);
+            m_activeX->GetEventHandler()->AddPendingEvent(event);
 
     };
 
 
     };
 
@@ -1166,9 +1170,35 @@ void wxActiveX::GetTypeInfo(ITypeInfo *ti, bool defInterface, bool defEventSink)
             ConnectAdvise(ta->guid, disp);
         };
 
             ConnectAdvise(ta->guid, disp);
         };
 
+        // Get properties
+        // See bug #1280715 in the wxActiveX SF project
+        int i;
+        for (i = 0; i < ta->cVars; i++) {
+            VARDESC FAR *vd = NULL;
+
+            typeInfo->GetVarDesc(i, &vd) ;
+            BSTR bstrProperty = NULL;
+            typeInfo->GetDocumentation(vd->memid, &bstrProperty,
+                                       NULL, NULL, NULL);
+            wxString propName(bstrProperty);
+            m_props.push_back(PropX());
+            int idx = m_props.size() - 1;
+            m_propNames[propName] = idx;
+            m_props[idx].name = propName;
+            m_props[idx].memid = vd->memid;
+
+            ParamX param;
+            param.isSafeArray = false;
+            param.isPtr = false;
+            param.flags = vd->elemdescVar.idldesc.wIDLFlags;
+            param.vt = vd->elemdescVar.tdesc.vt;
+
+            m_props[idx].arg = param;
+            m_props[idx].type = param;
+        }        
 
         // Get Function Names
 
         // Get Function Names
-        for (int i = 0; i < ta->cFuncs; i++)
+        for (i = 0; i < ta->cFuncs; i++)
         {
             FUNCDESC FAR *fd = NULL;
 
         {
             FUNCDESC FAR *fd = NULL;
 
@@ -1676,7 +1706,6 @@ void wxActiveX::OnPaint(wxPaintEvent& event)
 {
     wxLogTrace(wxT(""),wxT("repainting activex win"));
     wxPaintDC dc(this);
 {
     wxLogTrace(wxT(""),wxT("repainting activex win"));
     wxPaintDC dc(this);
-    dc.BeginDrawing();
     int w, h;
     GetSize(&w, &h);
     RECT posRect;
     int w, h;
     GetSize(&w, &h);
     RECT posRect;
@@ -1701,7 +1730,6 @@ void wxActiveX::OnPaint(wxPaintEvent& event)
         dc.DrawRectangle(0, 0, w, h);
         dc.SetBrush(wxNullBrush);
     }
         dc.DrawRectangle(0, 0, w, h);
         dc.SetBrush(wxNullBrush);
     }
-    dc.EndDrawing();
 }
 
 
 }
 
 
@@ -1771,6 +1799,16 @@ void wxActiveX::OnMouse(wxMouseEvent& event)
     wxLogTrace(wxT(""),wxT("msg sent"));
 }
 
     wxLogTrace(wxT(""),wxT("msg sent"));
 }
 
+bool wxActiveX::MSWTranslateMessage(WXMSG *msg){
+       
+       if (msg->message == WM_KEYDOWN){                
+               HRESULT result = m_oleInPlaceActiveObject->TranslateAccelerator(msg);
+               return (result == S_OK);
+       }
+       
+       return wxWindow::MSWTranslateMessage(msg);
+}
+
 long wxActiveX::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
 {
     if (m_oleObjectHWND == NULL)
 long wxActiveX::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
 {
     if (m_oleObjectHWND == NULL)