]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/msw/ole/activex.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/ole/activex.h
3 // Purpose: interface of wxActiveXEvent
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
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 receives an
25 ActiveX event parameters can get extremely complex and may be beyond the
26 abilities of wxVariant. If 'operator[]' fails, prints an error messages or
27 crashes the application, event handlers should use GetNativeParameters()
28 instead to obtain the original event information.
29 Calls to operator[] and GetNativeParmeters() can be mixed. It is valid
30 to handle some parameters of an event with operator[] and others directly
31 through GetNativeParameters(). It is \b not valid however to manipulate
32 the same parameter using both approaches at the same time.
39 class wxActiveXEvent
: public wxCommandEvent
43 Returns the dispatch id of this ActiveX event.
44 This is the numeric value from the .idl file specified by the id().
46 DISPID
GetDispatchId(int idx
) const;
49 Obtains the number of parameters passed through the ActiveX event.
51 size_t ParamCount() const;
54 Obtains the param name of the param number idx specifies as a string.
56 wxString
ParamName(size_t idx
) const;
59 Obtains the param type of the param number idx specifies as a string.
61 wxString
ParamType(size_t idx
) const;
64 Obtains the actual parameter value specified by idx.
66 wxVariant
operator[](size_t idx
);
69 Obtain the original MSW parameters for the event.
70 Event handlers can use this information to handle complex event parameters
71 that are beyond the scope of wxVariant.
72 The information returned here is the information passed to the original
74 \return a pointer to a struct containing the original MSW event parameters
76 wxActiveXEventNativeMSW
*GetNativeParameters() const;
82 @class wxActiveXContainer
84 wxActiveXContainer is a host for an ActiveX control on Windows (and as such
85 is a platform-specific class).
87 Note that the HWND that the class contains is the actual HWND of the ActiveX
88 control so using dynamic events and connecting to @c wxEVT_SIZE, for example,
89 will receive the actual size message sent to the control.
91 It is somewhat similar to the ATL class CAxWindow in operation.
93 The size of the ActiveX control's content is generally guaranteed to be that
94 of the client size of the parent of this wxActiveXContainer.
96 You can also process ActiveX events through wxActiveXEvent.
99 @section activexcontainer_example Example
101 This is an example of how to use the Adobe Acrobat Reader ActiveX control to
102 read PDF files (requires Acrobat Reader 4 and up).
103 Controls like this are typically found and dumped from OLEVIEW.exe that is
104 distributed with Microsoft Visual C++.
105 This example also demonstrates how to create a backend for wxMediaCtrl.
108 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
112 // http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACOverview.pdf
113 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
115 #include "wx/mediactrl.h" // wxMediaBackendCommonBase
116 #include "wx/msw/ole/activex.h" // wxActiveXContainer
117 #include "wx/msw/ole/automtn.h" // wxAutomationObject
119 const IID DIID__DPdf = {0xCA8A9781,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
120 const IID DIID__DPdfEvents = {0xCA8A9782,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
121 const CLSID CLSID_Pdf = {0xCA8A9780,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
123 class WXDLLIMPEXP_MEDIA wxPDFMediaBackend : public wxMediaBackendCommonBase
126 wxPDFMediaBackend() : m_pAX(NULL) {}
127 virtual ~wxPDFMediaBackend()
131 m_pAX->DissociateHandle();
135 virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
140 const wxValidator& validator,
141 const wxString& name)
143 IDispatch* pDispatch;
144 if( ::CoCreateInstance(CLSID_Pdf, NULL,
145 CLSCTX_INPROC_SERVER,
146 DIID__DPdf, (void**)&pDispatch) != 0 )
149 m_PDF.SetDispatchPtr(pDispatch); // wxAutomationObject will release itself
151 if ( !ctrl->wxControl::Create(parent, id, pos, size,
152 (style & ~wxBORDER_MASK) | wxBORDER_NONE,
156 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
157 m_pAX = new wxActiveXContainer(ctrl,
161 wxPDFMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE);
178 virtual bool Load(const wxString& fileName)
180 if(m_PDF.CallMethod("LoadFile", fileName).GetBool())
182 m_PDF.CallMethod("setCurrentPage", wxVariant((long)0));
183 NotifyMovieLoaded(); // initial refresh
185 m_pAX->OnSize(event);
191 virtual bool Load(const wxURI& location)
193 return m_PDF.CallMethod("LoadFile", location.BuildUnescapedURI()).GetBool();
195 virtual bool Load(const wxURI& WXUNUSED(location),
196 const wxURI& WXUNUSED(proxy))
201 virtual wxMediaState GetState()
203 return wxMEDIASTATE_STOPPED;
206 virtual bool SetPosition(wxLongLong where)
208 m_PDF.CallMethod("setCurrentPage", wxVariant((long)where.GetValue()));
211 virtual wxLongLong GetPosition()
215 virtual wxLongLong GetDuration()
220 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
221 int WXUNUSED(w), int WXUNUSED(h))
224 wxSize GetVideoSize() const
226 return wxDefaultSize;
229 virtual double GetPlaybackRate()
233 virtual bool SetPlaybackRate(double)
238 virtual double GetVolume()
242 virtual bool SetVolume(double)
247 virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags)
251 m_PDF.CallMethod("setShowToolbar", true);
252 m_PDF.CallMethod("setShowScrollbars", true);
256 m_PDF.CallMethod("setShowToolbar", false);
257 m_PDF.CallMethod("setShowScrollbars", false);
263 wxActiveXContainer* m_pAX;
264 wxAutomationObject m_PDF;
266 wxDECLARE_DYNAMIC_CLASS(wxPDFMediaBackend)
269 wxIMPLEMENT_DYNAMIC_CLASS(wxPDFMediaBackend, wxMediaBackend);
271 // Put this in one of your existing source files and then create a wxMediaCtrl with
272 wxMediaCtrl* mymediactrl = new wxMediaCtrl(this, "myfile.pdf", wxID_ANY,
273 wxDefaultPosition, wxSize(300,300),
274 0, "wxPDFMediaBackend");
275 // [this] is the parent window, "myfile.pdf" is the PDF file to open
284 @see wxActiveXEvent, @ref page_samples_flash
286 class wxActiveXContainer
: public wxControl
290 Creates this ActiveX container.
293 parent of this control. Must not be @NULL.
295 COM IID of pUnk to query. Must be a valid interface to an ActiveX control.
297 Interface of ActiveX control.
299 wxActiveXContainer(wxWindow
* parent
, REFIID iid
, IUnknown
* pUnk
);
301 Queries host's site for interface.
304 The iid of the required interface.
306 Double pointer to outgoing interface. Supply your own interface if desired.
308 The description of the outgoing interface.
310 Return true if interface supplied else return false.
312 virtual bool QueryClientSiteInterface(REFIID iid
, void **_interface
, const char *&desc
);