]>
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
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
11 An event class for handling ActiveX events passed from wxActiveXContainer.
13 ActiveX events are basically a function call with the parameters passed
14 through an array of wxVariants along with a return value that is a wxVariant
15 itself. What type the parameters or return value are depends on the context
16 (i.e. what the .idl specifies).
18 @beginEventTable{wxActiveXEvent}
19 @event{EVT_ACTIVEX(func)}
20 Sent when the ActiveX control hosted by wxActiveXContainer receives an
24 ActiveX event parameters can get extremely complex and may be beyond the
25 abilities of wxVariant. If 'operator[]' fails, prints an error messages or
26 crashes the application, event handlers should use GetNativeParameters()
27 instead to obtain the original event information.
28 Calls to operator[] and GetNativeParmeters() can be mixed. It is valid
29 to handle some parameters of an event with operator[] and others directly
30 through GetNativeParameters(). It is \b not valid however to manipulate
31 the same parameter using both approaches at the same time.
38 class wxActiveXEvent
: public wxCommandEvent
42 Returns the dispatch id of this ActiveX event.
43 This is the numeric value from the .idl file specified by the id().
45 DISPID
GetDispatchId(int idx
) const;
48 Obtains the number of parameters passed through the ActiveX event.
50 size_t ParamCount() const;
53 Obtains the param name of the param number idx specifies as a string.
55 wxString
ParamName(size_t idx
) const;
58 Obtains the param type of the param number idx specifies as a string.
60 wxString
ParamType(size_t idx
) const;
63 Obtains the actual parameter value specified by idx.
65 wxVariant
operator[](size_t idx
);
68 Obtain the original MSW parameters for the event.
69 Event handlers can use this information to handle complex event parameters
70 that are beyond the scope of wxVariant.
71 The information returned here is the information passed to the original
73 \return a pointer to a struct containing the original MSW event parameters
75 wxActiveXEventNativeMSW
*GetNativeParameters() const;
81 @class wxActiveXContainer
83 wxActiveXContainer is a host for an ActiveX control on Windows (and as such
84 is a platform-specific class).
86 Note that the HWND that the class contains is the actual HWND of the ActiveX
87 control so using dynamic events and connecting to @c wxEVT_SIZE, for example,
88 will receive the actual size message sent to the control.
90 It is somewhat similar to the ATL class CAxWindow in operation.
92 The size of the ActiveX control's content is generally guaranteed to be that
93 of the client size of the parent of this wxActiveXContainer.
95 You can also process ActiveX events through wxActiveXEvent.
98 @section activexcontainer_example Example
100 This is an example of how to use the Adobe Acrobat Reader ActiveX control to
101 read PDF files (requires Acrobat Reader 4 and up).
102 Controls like this are typically found and dumped from OLEVIEW.exe that is
103 distributed with Microsoft Visual C++.
104 This example also demonstrates how to create a backend for wxMediaCtrl.
107 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
111 // http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACOverview.pdf
112 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
114 #include "wx/mediactrl.h" // wxMediaBackendCommonBase
115 #include "wx/msw/ole/activex.h" // wxActiveXContainer
116 #include "wx/msw/ole/automtn.h" // wxAutomationObject
118 const IID DIID__DPdf = {0xCA8A9781,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
119 const IID DIID__DPdfEvents = {0xCA8A9782,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
120 const CLSID CLSID_Pdf = {0xCA8A9780,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
122 class WXDLLIMPEXP_MEDIA wxPDFMediaBackend : public wxMediaBackendCommonBase
125 wxPDFMediaBackend() : m_pAX(NULL) {}
126 virtual ~wxPDFMediaBackend()
130 m_pAX->DissociateHandle();
134 virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
139 const wxValidator& validator,
140 const wxString& name)
142 IDispatch* pDispatch;
143 if( ::CoCreateInstance(CLSID_Pdf, NULL,
144 CLSCTX_INPROC_SERVER,
145 DIID__DPdf, (void**)&pDispatch) != 0 )
148 m_PDF.SetDispatchPtr(pDispatch); // wxAutomationObject will release itself
150 if ( !ctrl->wxControl::Create(parent, id, pos, size,
151 (style & ~wxBORDER_MASK) | wxBORDER_NONE,
155 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
156 m_pAX = new wxActiveXContainer(ctrl,
160 wxPDFMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE);
177 virtual bool Load(const wxString& fileName)
179 if(m_PDF.CallMethod("LoadFile", fileName).GetBool())
181 m_PDF.CallMethod("setCurrentPage", wxVariant((long)0));
182 NotifyMovieLoaded(); // initial refresh
184 m_pAX->OnSize(event);
190 virtual bool Load(const wxURI& location)
192 return m_PDF.CallMethod("LoadFile", location.BuildUnescapedURI()).GetBool();
194 virtual bool Load(const wxURI& WXUNUSED(location),
195 const wxURI& WXUNUSED(proxy))
200 virtual wxMediaState GetState()
202 return wxMEDIASTATE_STOPPED;
205 virtual bool SetPosition(wxLongLong where)
207 m_PDF.CallMethod("setCurrentPage", wxVariant((long)where.GetValue()));
210 virtual wxLongLong GetPosition()
214 virtual wxLongLong GetDuration()
219 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
220 int WXUNUSED(w), int WXUNUSED(h))
223 wxSize GetVideoSize() const
225 return wxDefaultSize;
228 virtual double GetPlaybackRate()
232 virtual bool SetPlaybackRate(double)
237 virtual double GetVolume()
241 virtual bool SetVolume(double)
246 virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags)
250 m_PDF.CallMethod("setShowToolbar", true);
251 m_PDF.CallMethod("setShowScrollbars", true);
255 m_PDF.CallMethod("setShowToolbar", false);
256 m_PDF.CallMethod("setShowScrollbars", false);
262 wxActiveXContainer* m_pAX;
263 wxAutomationObject m_PDF;
265 wxDECLARE_DYNAMIC_CLASS(wxPDFMediaBackend)
268 wxIMPLEMENT_DYNAMIC_CLASS(wxPDFMediaBackend, wxMediaBackend);
270 // Put this in one of your existing source files and then create a wxMediaCtrl with
271 wxMediaCtrl* mymediactrl = new wxMediaCtrl(this, "myfile.pdf", wxID_ANY,
272 wxDefaultPosition, wxSize(300,300),
273 0, "wxPDFMediaBackend");
274 // [this] is the parent window, "myfile.pdf" is the PDF file to open
283 @see wxActiveXEvent, @ref page_samples_flash
285 class wxActiveXContainer
: public wxControl
289 Creates this ActiveX container.
292 parent of this control. Must not be @NULL.
294 COM IID of pUnk to query. Must be a valid interface to an ActiveX control.
296 Interface of ActiveX control.
298 wxActiveXContainer(wxWindow
* parent
, REFIID iid
, IUnknown
* pUnk
);
300 Queries host's site for interface.
303 The iid of the required interface.
305 Double pointer to outgoing interface. Supply your own interface if desired.
307 The description of the outgoing interface.
309 Return true if interface supplied else return false.
311 virtual bool QueryClientSiteInterface(REFIID iid
, void **_interface
, const char *&desc
);