Hi, 

Main purpose of this mail is to publish the attached diff for Wx-ActiveX which 
allows compilation with the current Wx versions. I am not the original author 
of any of it. Rather it is just all the patches and instructions that have been 
posted here over the years brought together. Now the mailing list is easy to 
search it seems a good place to post it.

Compilation with the current version of mingw32 does not work (win32api-3.9). 
If using the latest mingw32 you need to either:

1) Get a different version of libuuid.a ( the one from win32api-3.7 would work 
).
or
2) Install the platform SDK from Microsoft and link against Uuid.lib

Both methods will work.


Regards


Mark
diff -r -u -w activex/IEHtmlWin.cpp activex/IEHtmlWin.cpp
--- activex/IEHtmlWin.cpp       2003-07-25 19:24:44.000000000 +0100
+++ activex/IEHtmlWin.cpp       2007-07-13 00:25:20.937500000 +0100
@@ -312,7 +312,7 @@
 {
     try
     {
-        CallMethod("GoHome");
+        CallMethod(wxT("GoHome"));
         return true;
     }
     catch(exception&)
@@ -408,7 +408,7 @@
 {
        wxAutoOleInterface<IHTMLTxtRange> tr(GetSelRange(m_oleObject));
     if (! tr)
-       return "";
+       return wxT("");
 
     BSTR text = NULL;
     HRESULT hr = E_FAIL;
@@ -418,7 +418,7 @@
        else
                hr = tr->get_text(&text);
     if (hr != S_OK)
-       return "";
+       return wxT("");
 
     wxString s = text;
     SysFreeString(text);
@@ -429,26 +429,26 @@
 wxString wxIEHtmlWin::GetText(bool asHTML)
 {
        if (! m_webBrowser.Ok())
-               return "";
+               return wxT("");
 
        // get document dispatch interface
        IDispatch *iDisp = NULL;
     HRESULT hr = m_webBrowser->get_Document(&iDisp);
     if (hr != S_OK)
-       return "";
+       return wxT("");
 
        // Query for Document Interface
     wxAutoOleInterface<IHTMLDocument2> hd(IID_IHTMLDocument2, iDisp);
     iDisp->Release();
 
     if (! hd.Ok())
-               return "";
+               return wxT("");
 
        // get body element
        IHTMLElement *_body = NULL;
        hd->get_body(&_body);
        if (! _body)
-               return "";
+               return wxT("");
        wxAutoOleInterface<IHTMLElement> body(_body);
 
        // get inner text
@@ -460,7 +460,7 @@
        else
                hr = body->get_innerText(&text);
     if (hr != S_OK)
-       return "";
+       return wxT("");
 
     wxString s = text;
     SysFreeString(text);
diff -r -u -w wxActiveX/activex/wxactivex.cpp activex/wxactivex.cpp
--- activex/wxactivex.cpp       2007-03-12 21:41:47.187500000 +0000
+++ activex/wxactivex.cpp       2007-07-13 00:25:20.984375000 +0100
@@ -266,35 +266,35 @@
 
     switch (vt)
     {
-    VT(VT_SAFEARRAY, "SafeArray");
-    VT(VT_EMPTY, "empty");
-    VT(VT_NULL, "null");
-    VT(VT_UI1, "byte");
-    VT(VT_I1, "char");
-    VT(VT_I2, "short");
-    VT(VT_I4, "long");
-    VT(VT_UI2, "unsigned short");
-    VT(VT_UI4, "unsigned long");
-    VT(VT_INT, "int");
-    VT(VT_UINT, "unsigned int");
-    VT(VT_R4, "real(4)");
-    VT(VT_R8, "real(8)");
-    VT(VT_CY, "Currency");
-    VT(VT_DATE, "wxDate");
-    VT(VT_BSTR, "wxString");
-    VT(VT_DISPATCH, "IDispatch");
-    VT(VT_ERROR, "SCode Error");
-    VT(VT_BOOL, "bool");
-    VT(VT_VARIANT, "wxVariant");
-    VT(VT_UNKNOWN, "IUknown");
-    VT(VT_VOID, "void");
-    VT(VT_PTR, "void *");
-    VT(VT_USERDEFINED, "*user defined*");
+    VT(VT_SAFEARRAY, wxT("SafeArray"));
+    VT(VT_EMPTY, wxT("empty"));
+    VT(VT_NULL, wxT("null"));
+    VT(VT_UI1, wxT("byte"));
+    VT(VT_I1, wxT("char"));
+    VT(VT_I2, wxT("short"));
+    VT(VT_I4, wxT("long"));
+    VT(VT_UI2, wxT("unsigned short"));
+    VT(VT_UI4, wxT("unsigned long"));
+    VT(VT_INT, wxT("int"));
+    VT(VT_UINT, wxT("unsigned int"));
+    VT(VT_R4, wxT("real(4)"));
+    VT(VT_R8, wxT("real(8)"));
+    VT(VT_CY, wxT("Currency"));
+    VT(VT_DATE, wxT("wxDate"));
+    VT(VT_BSTR, wxT("wxString"));
+    VT(VT_DISPATCH, wxT("IDispatch"));
+    VT(VT_ERROR, wxT("SCode Error"));
+    VT(VT_BOOL, wxT("bool"));
+    VT(VT_VARIANT, wxT("wxVariant"));
+    VT(VT_UNKNOWN, wxT("IUknown"));
+    VT(VT_VOID, wxT("void"));
+    VT(VT_PTR, wxT("void *"));
+    VT(VT_USERDEFINED, wxT("*user defined*"));
 
     default:
         {
             wxString s;
-            s << "Unknown(" << vt << ")";
+            s << wxT("Unknown(") << vt << wxT(")");
             return s;
         };
     };
@@ -304,7 +304,7 @@
 
 void wxActiveX::CreateActiveX(REFCLSID clsid)
 {
-       SetTransparent();
+    //SetTransparent();
 
        HRESULT hret;
 
@@ -618,9 +618,9 @@
        case VT_I1:
        case VT_UI1:
                if (byRef)
-                       vx = (char) *va.pbVal;
+            vx = (wxChar) *va.pbVal;
                else
-                       vx = (char) va.bVal;
+            vx = (wxChar) va.bVal;
                return true;
 
        // 2 byte shorts
@@ -753,9 +753,9 @@
        case VT_I1:
        case VT_UI1:
                if (byRef)
-                       *va.pbVal = (char) vx;
+            *va.pbVal = (wxChar) vx;
                else
-                       va.bVal = (char) vx;
+            va.bVal = (wxChar) vx;
                return true;
 
        // 2 byte shorts
@@ -1052,12 +1052,12 @@
             return m_params[i];
     };
 
-    wxString err = "wxActiveXEvent::operator[] invalid name <" + name + ">";
-    err += "\r\nValid Names = :\r\n";
+    wxString err = wxT("wxActiveXEvent::operator[] invalid name <") + name + 
wxT(">");
+    err += wxT("\r\nValid Names = :\r\n");
     for (i = 0; i < m_params.GetCount(); i++)
     {
         err += m_params[i].GetName();
-        err += "\r\n";
+        err += wxT("\r\n");
     };
 
     wxASSERT_MSG(false, err);
@@ -1286,7 +1286,7 @@
 
 wxString wxActiveX::GetEventName(int idx) {
      if (idx < 0 || idx >= this->GetEventCount() ) {
-       wxString tmp = "" ;
+       wxString tmp = wxT("") ;
        return( tmp ) ;
      }
      const wxActiveX::FuncX& func = this->GetEventDesc(idx);
@@ -1295,7 +1295,7 @@
 
 wxString wxActiveX::GetPropName(int idx) {
      if (idx < 0 || idx >= this->GetPropCount() ) {
-       wxString tmp = "" ;
+       wxString tmp = wxT("") ;
        return( tmp ) ;
      }
 
@@ -1305,7 +1305,7 @@
 
 wxString wxActiveX::GetMethodName(int idx) {
      if (idx < 0 || idx >= this->GetMethodCount() ) {
-       wxString tmp = "" ;
+       wxString tmp = wxT("") ;
        return( tmp ) ;
      }
      const wxActiveX::FuncX& func = this->GetMethodDesc(idx);
@@ -1331,7 +1331,7 @@
 
 wxString wxActiveX::GetMethodArgName(int idx , int argx) {
      if (idx < 0 || idx >= this->GetMethodCount() ) {
-       wxString tmp = "" ;
+       wxString tmp = wxT("") ;
        return( tmp ) ;
      }
      const wxActiveX::FuncX& func = this->GetMethodDesc(idx);
@@ -1374,7 +1374,7 @@
     if (it == m_props.end())
     {
         wxString s;
-        s << "property <" << name << "> not found";
+        s << wxT("property <") << name << wxT("> not found");
         croak(s.mb_str());
     };
 
@@ -1403,7 +1403,7 @@
     if (it == m_methods.end())
     {
         wxString s;
-        s << "method <" << name << "> not found";
+        s << wxT("method <") << name << wxT("> not found");
         croak(s.mb_str());
     };
 
@@ -1434,7 +1434,7 @@
     if (! prop.CanSet())
     {
         wxString s;
-        s << "property <" << name << "> is readonly";
+        s << wxT("property <") << name << wxT("> is readonly");
         croak(s.mb_str());
     };
 
@@ -1471,7 +1471,7 @@
     if (! prop.CanGet())
     {
         wxString s;
-        s << "property <" << name << "> is writeonly";
+        s << wxT("property <") << name << wxT("> is writeonly");
                croak(s.mb_str());
     };
 
@@ -1819,9 +1819,9 @@
 
 void wxActiveX::OnPaint(wxPaintEvent& event)
 {
-       wxLogTrace(wxT("repainting activex win"));
+    wxLogTrace('%s', wxT("repainting activex win"));
        wxPaintDC dc(this);
-       dc.BeginDrawing();
+    // dc.BeginDrawing(); // deprecated
        int w, h;
        GetSize(&w, &h);
        RECT posRect;
@@ -1846,7 +1846,7 @@
                dc.DrawRectangle(0, 0, w, h);
                dc.SetBrush(wxNullBrush);
        }
-       dc.EndDrawing();
+    // dc.EndDrawing();  // deprecated
 }
 
 
@@ -1854,12 +1854,11 @@
 {
        if (m_oleObjectHWND == NULL)
     {
-        wxLogTrace(wxT("no oleInPlaceObject"));
+        wxLogTrace('%s', wxT("no oleInPlaceObject"));
         event.Skip();
         return;
     }
-
-       wxLogTrace(wxT("mouse event"));
+    wxLogTrace('%s', wxT("mouse event"));
        UINT msg = 0;
        WPARAM wParam = 0;
        LPARAM lParam = 0;
@@ -1902,18 +1901,17 @@
        wxString log;
        if (msg == 0)
     {
-        wxLogTrace(wxT("no message"));
+        wxLogTrace('%s', wxT("no message"));
         event.Skip(); return;
     };
 
        if (!::SendMessage(m_oleObjectHWND, msg, wParam, lParam))
     {
-        wxLogTrace(wxT("msg not delivered"));
         event.Skip();
+        wxLogTrace('%s', wxT("msg not delivered"));
         return;
     };
-
-       wxLogTrace(wxT("msg sent"));
+    wxLogTrace('%s', wxT("msg sent"));
 }
 
 long wxActiveX::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
@@ -2640,7 +2638,7 @@
 
 bool GetSysErrMessage(int err, wxString& s)
 {
-       char buf[256];
+    wxChar buf[256];
        if (FormatMessage(
                FORMAT_MESSAGE_FROM_SYSTEM, NULL,
                err,0, buf, sizeof(buf), NULL) == 0)
@@ -2661,73 +2659,71 @@
     switch (hr)
     {
     case S_OK:
-       return "";
+        return wxT("");
 
        case CONNECT_E_CANNOTCONNECT:
-               return "Cannot connect to event interface (maybe not there ?) - 
see MSDN";
+        return wxT("Cannot connect to event interface (maybe not there ?) - 
see MSDN");
 
     case DISP_E_MEMBERNOTFOUND:
-        return "The requested member does not exist, or the call to Invoke 
tried to set the value of a read-only property.";
+        return wxT("The requested member does not exist, or the call to Invoke 
tried to set the value of a read-only property.");
 
     case DISP_E_BADVARTYPE:
-        return "One of the parameters in rgvarg is not a valid variant type.";
+        return wxT("One of the parameters in rgvarg is not a valid variant 
type.");
 
     case DISP_E_BADPARAMCOUNT:
-        return "The number of elements provided to DISPPARAMS is different 
from the number of parameters accepted by the method or property";
+        return wxT("The number of elements provided to DISPPARAMS is different 
from the number of parameters accepted by the method or property");
 
     case DISP_E_EXCEPTION:
-        return "The application needs to raise an exception. In this case, the 
structure passed in pExcepInfo should be filled in.";
+        return wxT("The application needs to raise an exception. In this case, 
the structure passed in pExcepInfo should be filled in.");
 
     case DISP_E_TYPEMISMATCH:
-        return "One or more of the parameters could not be coerced. The index 
within rgvarg of the first parameter with the incorrect type is returned in the 
puArgErr parameter.";
+        return wxT("One or more of the parameters could not be coerced. The 
index within rgvarg of the first parameter with the incorrect type is returned 
in the puArgErr parameter.");
 
     case DISP_E_PARAMNOTOPTIONAL:
-        return "A required parameter was omitted.";
+        return wxT("A required parameter was omitted.");
 
        case DISP_E_PARAMNOTFOUND:
-               return "One of the parameter DISPIDs does not correspond to a 
parameter on the method. In this case, puArgErr should be set to the first 
parameter that contains the error.";
+        return wxT("One of the parameter DISPIDs does not correspond to a 
parameter on the method. In this case, puArgErr should be set to the first 
parameter that contains the error.");
 
     case OLECMDERR_E_UNKNOWNGROUP:
-               return "The pguidCmdGroup parameter is not NULL but does not 
specify a recognized command group.";
+        return wxT("The pguidCmdGroup parameter is not NULL but does not 
specify a recognized command group.");
 
     case OLECMDERR_E_NOTSUPPORTED:
-               return "The nCmdID parameter is not a valid command in the 
group identified by pguidCmdGroup.";
+        return wxT("The nCmdID parameter is not a valid command in the group 
identified by pguidCmdGroup.");
 
     case OLECMDERR_E_DISABLED:
-               return "The command identified by nCmdID is currently disabled 
and cannot be executed.";
+        return wxT("The command identified by nCmdID is currently disabled and 
cannot be executed.");
 
     case OLECMDERR_E_NOHELP:
-               return "The caller has asked for help on the command identified 
by nCmdID, but no help is available.";
+        return wxT("The caller has asked for help on the command identified by 
nCmdID, but no help is available.");
 
     case OLECMDERR_E_CANCELED:
-               return "The user canceled the execution of the command.";
+        return wxT("The user canceled the execution of the command.");
 
     case E_INVALIDARG:
-        return "E_INVALIDARG";
+        return wxT("E_INVALIDARG");
 
     case E_OUTOFMEMORY:
-        return "E_OUTOFMEMORY";
+        return wxT("E_OUTOFMEMORY");
 
     case E_NOINTERFACE:
-        return "E_NOINTERFACE";
+        return wxT("E_NOINTERFACE");
 
     case E_UNEXPECTED:
-        return "E_UNEXPECTED";
+        return wxT("E_UNEXPECTED");
 
     case STG_E_INVALIDFLAG:
-        return "STG_E_INVALIDFLAG";
+        return wxT("STG_E_INVALIDFLAG");
 
     case E_FAIL:
-        return "E_FAIL";
+        return wxT("E_FAIL");
 
     case E_NOTIMPL:
-        return "E_NOTIMPL";
+        return wxT("E_NOTIMPL");
 
     default:
         {
-            char buf[64];
-            sprintf(buf, "Unknown - 0x%X", hr);
-            return wxString(buf);
+            return wxString::Format(wxT("Unknown - 0x%X"), hr);
         }
     };
 };
@@ -2861,6 +2857,6 @@
       return s;
   }
   else
-      return "StringFromIID() error";
+      return wxT("StringFromIID() error");
 }
 
diff -r -u -w ActiveX.xs ActiveX.xs
--- ActiveX.xs  2003-07-21 13:21:32.000000000 +0100
+++ ActiveX.xs  2007-07-13 00:33:29.250000000 +0100
@@ -33,8 +33,8 @@
 
 BOOT:
   INIT_PLI_HELPERS( wx_pli_helpers );
-  wxClassInfo::CleanUpClasses();
-  wxClassInfo::InitializeClasses();
+//  wxClassInfo::CleanUpClasses();
+//  wxClassInfo::InitializeClasses();
 
 #undef THIS
 
@@ -203,7 +203,30 @@
   IDispatch * pDispatch;
 
   ST(0) = &PL_sv_undef;
-  hmodule = LoadLibrary("OLE");
+  // hmodule = LoadLibrary(_T("OLE"));  //replaced with GetModuleHandle
+  // Fix for packagers - as per Win32::GUI::AxWindow
+  
+  // Try to find OLE.dll
+    hmodule = GetModuleHandle(_T("OLE"));
+    if (hmodule == 0) {
+      // Try to find using Dynaloader
+      AV* av_modules = get_av("DynaLoader::dl_modules", FALSE);
+      AV* av_librefs = get_av("DynaLoader::dl_librefs", FALSE);
+      if (av_modules && av_librefs) {
+        // Look at Win32::OLE package
+        for (I32 i = 0; i < av_len(av_modules); i++) {
+          SV** sv = av_fetch(av_modules, i, 0);
+          if (sv && SvPOK (*sv) &&
+              strEQ(SvPV_nolen(*sv), "Win32::OLE")) {
+            // Tahe
+            sv = av_fetch(av_librefs, i, 0);
+            hmodule = (HMODULE) (sv && SvIOK (*sv) ? SvIV(*sv) : 0);
+            break;
+          }
+        }
+      }
+  }
+  
   if (hmodule != 0) {
     pCreatePerlObject = (MYPROC) GetProcAddress(hmodule, "CreatePerlObject");
     if (pCreatePerlObject != 0)  {
@@ -216,7 +239,7 @@
       ST(0) = (pCreatePerlObject)(aTHX_ stash, pDispatch, NULL);
 #endif
     }
-    FreeLibrary(hmodule);
+  // FreeLibrary(hmodule);  // LoadLibrary no longer called
   }
 }
 
diff -r -u -w lib/Wx/ActiveX.pm lib/Wx/ActiveX.pm
--- lib/Wx/ActiveX.pm   2003-08-08 06:55:46.000000000 +0100
+++ lib/Wx/ActiveX.pm   2007-07-13 00:25:21.031250000 +0100
@@ -32,7 +32,7 @@
 
 sub BEGIN {
   @ISA = qw(Wx::Window);
-  $VERSION = '0.05';
+  $VERSION = '0.051';
   Wx::wx_boot( 'Wx::ActiveX', $VERSION ) ;
   $XS_NEW = \&new ;
   *new = \&PLnew ;

Reply via email to