]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/msw/ole/activex.h
74b7d22a1b4588f65fd761501acacb5d461b525a
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/ole/activex.h
3 // Purpose: interface of wxActiveXEvent
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 An event class for handling ActiveX events passed from wxActiveXContainer.
14 ActiveX events are basically a function call with the parameters passed
15 through an array of wxVariants along with a return value that is a wxVariant
16 itself. What type the parameters or return value are depends on the context
17 (i.e. what the .idl specifies).
19 @beginEventTable{wxActiveXEvent}
20 @event{EVT_ACTIVEX(func)}
21 Sent when the ActiveX control hosted by wxActiveXContainer recieves an
30 class wxActiveXEvent
: public wxCommandEvent
34 Returns the dispatch id of this ActiveX event.
35 This is the numeric value from the .idl file specified by the id().
37 DISPID
GetDispatchId(int idx
) const;
40 Obtains the number of parameters passed through the ActiveX event.
42 size_t ParamCount() const;
45 Obtains the param name of the param number idx specifies as a string.
47 wxString
ParamName(size_t idx
) const;
50 Obtains the param type of the param number idx specifies as a string.
52 wxString
ParamType(size_t idx
) const;
55 Obtains the actual parameter value specified by idx.
57 wxVariant
operator[](size_t idx
);
63 @class wxActiveXContainer
65 wxActiveXContainer is a host for an ActiveX control on Windows (and as such
66 is a platform-specific class).
68 Note that the HWND that the class contains is the actual HWND of the ActiveX
69 control so using dynamic events and connecting to wxEVT_SIZE, for example,
70 will receive the actual size message sent to the control.
72 It is somewhat similar to the ATL class CAxWindow in operation.
74 The size of the ActiveX control's content is generally guaranteed to be that
75 of the client size of the parent of this wxActiveXContainer.
77 You can also process ActiveX events through wxActiveXEvent.
80 @section activexcontainer_example Example
82 This is an example of how to use the Adobe Acrobat Reader ActiveX control to
83 read PDF files (requires Acrobat Reader 4 and up).
84 Controls like this are typically found and dumped from OLEVIEW.exe that is
85 distributed with Microsoft Visual C++.
86 This example also demonstrates how to create a backend for wxMediaCtrl.
89 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
93 // http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACOverview.pdf
94 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
96 #include "wx/mediactrl.h" // wxMediaBackendCommonBase
97 #include "wx/msw/ole/activex.h" // wxActiveXContainer
98 #include "wx/msw/ole/automtn.h" // wxAutomationObject
100 const IID DIID__DPdf = {0xCA8A9781,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
101 const IID DIID__DPdfEvents = {0xCA8A9782,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
102 const CLSID CLSID_Pdf = {0xCA8A9780,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
104 class WXDLLIMPEXP_MEDIA wxPDFMediaBackend : public wxMediaBackendCommonBase
107 wxPDFMediaBackend() : m_pAX(NULL) {}
108 virtual ~wxPDFMediaBackend()
112 m_pAX->DissociateHandle();
116 virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
121 const wxValidator& validator,
122 const wxString& name)
124 IDispatch* pDispatch;
125 if( ::CoCreateInstance(CLSID_Pdf, NULL,
126 CLSCTX_INPROC_SERVER,
127 DIID__DPdf, (void**)&pDispatch) != 0 )
130 m_PDF.SetDispatchPtr(pDispatch); // wxAutomationObject will release itself
132 if ( !ctrl->wxControl::Create(parent, id, pos, size,
133 (style & ~wxBORDER_MASK) | wxBORDER_NONE,
137 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
138 m_pAX = new wxActiveXContainer(ctrl,
142 wxPDFMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE);
159 virtual bool Load(const wxString& fileName)
161 if(m_PDF.CallMethod(wxT("LoadFile"), fileName).GetBool())
163 m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)0));
164 NotifyMovieLoaded(); // initial refresh
166 m_pAX->OnSize(event);
172 virtual bool Load(const wxURI& location)
174 return m_PDF.CallMethod(wxT("LoadFile"), location.BuildUnescapedURI()).GetBool();
176 virtual bool Load(const wxURI& WXUNUSED(location),
177 const wxURI& WXUNUSED(proxy))
182 virtual wxMediaState GetState()
184 return wxMEDIASTATE_STOPPED;
187 virtual bool SetPosition(wxLongLong where)
189 m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)where.GetValue()));
192 virtual wxLongLong GetPosition()
196 virtual wxLongLong GetDuration()
201 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
202 int WXUNUSED(w), int WXUNUSED(h))
205 wxSize GetVideoSize() const
207 return wxDefaultSize;
210 virtual double GetPlaybackRate()
214 virtual bool SetPlaybackRate(double)
219 virtual double GetVolume()
223 virtual bool SetVolume(double)
228 virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags)
232 m_PDF.CallMethod(wxT("setShowToolbar"), true);
233 m_PDF.CallMethod(wxT("setShowScrollbars"), true);
237 m_PDF.CallMethod(wxT("setShowToolbar"), false);
238 m_PDF.CallMethod(wxT("setShowScrollbars"), false);
244 wxActiveXContainer* m_pAX;
245 wxAutomationObject m_PDF;
247 DECLARE_DYNAMIC_CLASS(wxPDFMediaBackend)
250 IMPLEMENT_DYNAMIC_CLASS(wxPDFMediaBackend, wxMediaBackend);
251 Put this in one of your existant source files and then create a wxMediaCtrl with
253 //[this] is the parent window, "myfile.pdf" is the PDF file to open
254 wxMediaCtrl* mymediactrl = new wxMediaCtrl(this, wxT("myfile.pdf"), wxID_ANY,
255 wxDefaultPosition, wxSize(300,300),
256 0, wxT("wxPDFMediaBackend"));
265 @see wxActiveXEvent, @ref page_samples_flash Flash sample
267 class wxActiveXContainer
: public wxControl
271 Creates this ActiveX container.
274 parent of this control. Must not be @NULL.
276 COM IID of pUnk to query. Must be a valid interface to an ActiveX control.
278 Interface of ActiveX control.
280 wxActiveXContainer(wxWindow
* parent
, REFIID iid
, IUnknown
* pUnk
);