wxactivexcontainerwxactivexcontainer is a host for an activex control on windows (and as such is a platform-specific class). note that the hwnd that the class contains is the actual hwnd of the activex control so using dynamic events and connecting to wxevt_size, for example, will recieve the actual size message sent to the control. it is somewhat similar to the atl class caxwindow in operation. the size of the activex control's content is generally gauranteed to be that of the client size of the parent of this wxactivexcontainer. you can also process activex events through wxevt_activex or the corresponding message map macro evt_activex. see also derived from include files <wx/msw/ole/activex.h> example this is an example of how to use the adobe acrobat reader activex control to read pdf files (requires acrobat reader 4 and up). controls like this are typically found and dumped from oleview.exe that is distributed with microsoft visual c++. this example also demonstrates how to create a backend for wxmediactrl.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // wxpdfmediabackend // // http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/iacoverview.pdf //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #include "wx/mediactrl.h" // wxmediabackendcommonbase #include "wx/msw/ole/activex.h" // wxactivexcontainer #include "wx/msw/ole/automtn.h" // wxautomationobject const iid diid__dpdf = {0xca8a9781,0x280d,0x11cf,{0xa2,0x4d,0x44,0x45,0x53,0x54,0x00,0x00}}; const iid diid__dpdfevents = {0xca8a9782,0x280d,0x11cf,{0xa2,0x4d,0x44,0x45,0x53,0x54,0x00,0x00}}; const clsid clsid_pdf = {0xca8a9780,0x280d,0x11cf,{0xa2,0x4d,0x44,0x45,0x53,0x54,0x00,0x00}}; class wxdllimpexp_media wxpdfmediabackend : public wxmediabackendcommonbase { public: wxpdfmediabackend() : m_pax(null) {} virtual ~wxpdfmediabackend() { if(m_pax) { m_pax->dissociatehandle(); delete m_pax; } } virtual bool createcontrol(wxcontrol* ctrl, wxwindow* parent, wxwindowid id, const wxpoint& pos, const wxsize& size, long style, const wxvalidator& validator, const wxstring& name) { idispatch* pdispatch; if( ::cocreateinstance(clsid_pdf, null, clsctx_inproc_server, diid__dpdf, (void**)&pdispatch) != 0 ) return false; m_pdf.setdispatchptr(pdispatch); // wxautomationobject will release itself if ( !ctrl->wxcontrol::create(parent, id, pos, size, (style & ~wxborder_mask) | wxborder_none, validator, name) ) return false; m_ctrl = wxstaticcast(ctrl, wxmediactrl); m_pax = new wxactivexcontainer(ctrl, diid__dpdf, pdispatch); wxpdfmediabackend::showplayercontrols(wxmediactrlplayercontrols_none); return true; } virtual bool play() { return true; } virtual bool pause() { return true; } virtual bool stop() { return true; } virtual bool load(const wxstring& filename) { if(m_pdf.callmethod(wxt("loadfile"), filename).getbool()) { m_pdf.callmethod(wxt("setcurrentpage"), wxvariant((long)0)); notifymovieloaded(); // initial refresh wxsizeevent event; m_pax->onsize(event); return true; } return false; } virtual bool load(const wxuri& location) { return m_pdf.callmethod(wxt("loadfile"), location.buildunescapeduri()).getbool(); } virtual bool load(const wxuri& wxunused(location), const wxuri& wxunused(proxy)) { return false; } virtual wxmediastate getstate() { return wxmediastate_stopped; } virtual bool setposition(wxlonglong where) { m_pdf.callmethod(wxt("setcurrentpage"), wxvariant((long)where.getvalue())); return true; } virtual wxlonglong getposition() { return 0; } virtual wxlonglong getduration() { return 0; } virtual void move(int wxunused(x), int wxunused(y), int wxunused(w), int wxunused(h)) { } wxsize getvideosize() const { return wxdefaultsize; } virtual double getplaybackrate() { return 0; } virtual bool setplaybackrate(double) { return false; } virtual double getvolume() { return 0; } virtual bool setvolume(double) { return false; } virtual bool showplayercontrols(wxmediactrlplayercontrols flags) { if(flags) { m_pdf.callmethod(wxt("setshowtoolbar"), true); m_pdf.callmethod(wxt("setshowscrollbars"), true); } else { m_pdf.callmethod(wxt("setshowtoolbar"), false); m_pdf.callmethod(wxt("setshowscrollbars"), false); } return true; } wxactivexcontainer* m_pax; wxautomationobject m_pdf; declare_dynamic_class(wxpdfmediabackend) }; implement_dynamic_class(wxpdfmediabackend, wxmediabackend);put this in one of your existant source files and then create a wxmediactrl with //[this] is the parent window, "myfile.pdf" is the pdf file to open wxmediactrl* mymediactrl = new wxmediactrl(this, wxt("myfile.pdf"), wxid_any, wxdefaultposition, wxsize(300,300), 0, wxt("wxpdfmediabackend"));members
wxactivexcontainer::wxactivexcontainer
wxactivexcontainer::wxactivexcontainerwxactivexcontainer( wxwindow* parent, refiid iid, iunknown* punk, ) creates this activex container. parent
|