]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/msw/ole/activex.h
Fix typo and a leftover.
[wxWidgets.git] / interface / wx / msw / ole / activex.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: msw/ole/activex.h
e54c96f1 3// Purpose: interface of wxActiveXEvent
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxActiveXEvent
4cc4bfaf 11
213b5041 12 An event class for handling ActiveX events passed from wxActiveXContainer.
d9faa1fe
FM
13
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).
4cc4bfaf 18
dd72e767
FM
19 @beginEventTable{wxActiveXEvent}
20 @event{EVT_ACTIVEX(func)}
213b5041
VZ
21 Sent when the ActiveX control hosted by wxActiveXContainer recieves an
22 ActiveX event.
dd72e767
FM
23 @endEventTable
24
2ddb8ccf
VZ
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.
33
d9faa1fe
FM
34 @onlyfor{wxmsw}
35
213b5041 36 @library{wxcore}
dd72e767 37 @category{events}
23324ae1
FM
38*/
39class wxActiveXEvent : public wxCommandEvent
40{
41public:
42 /**
213b5041 43 Returns the dispatch id of this ActiveX event.
dd72e767 44 This is the numeric value from the .idl file specified by the id().
23324ae1 45 */
328f5751 46 DISPID GetDispatchId(int idx) const;
23324ae1
FM
47
48 /**
213b5041 49 Obtains the number of parameters passed through the ActiveX event.
23324ae1 50 */
328f5751 51 size_t ParamCount() const;
23324ae1
FM
52
53 /**
54 Obtains the param name of the param number idx specifies as a string.
55 */
328f5751 56 wxString ParamName(size_t idx) const;
23324ae1
FM
57
58 /**
59 Obtains the param type of the param number idx specifies as a string.
60 */
328f5751 61 wxString ParamType(size_t idx) const;
23324ae1
FM
62
63 /**
64 Obtains the actual parameter value specified by idx.
65 */
66 wxVariant operator[](size_t idx);
2ddb8ccf
VZ
67
68 /**
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
73 'Invoke' method call.
74 \return a pointer to a struct containing the original MSW event parameters
75 */
76 wxActiveXEventNativeMSW *GetNativeParameters() const;
23324ae1
FM
77};
78
79
e54c96f1 80
23324ae1
FM
81/**
82 @class wxActiveXContainer
4cc4bfaf 83
213b5041 84 wxActiveXContainer is a host for an ActiveX control on Windows (and as such
dd72e767
FM
85 is a platform-specific class).
86
213b5041 87 Note that the HWND that the class contains is the actual HWND of the ActiveX
dd72e767 88 control so using dynamic events and connecting to wxEVT_SIZE, for example,
213b5041 89 will receive the actual size message sent to the control.
4cc4bfaf 90
23324ae1 91 It is somewhat similar to the ATL class CAxWindow in operation.
4cc4bfaf 92
213b5041 93 The size of the ActiveX control's content is generally guaranteed to be that
23324ae1 94 of the client size of the parent of this wxActiveXContainer.
4cc4bfaf 95
213b5041 96 You can also process ActiveX events through wxActiveXEvent.
dd72e767
FM
97
98
99 @section activexcontainer_example Example
100
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.
106
107 @code
108 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
109 //
110 // wxPDFMediaBackend
111 //
112 // http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACOverview.pdf
113 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
114
115 #include "wx/mediactrl.h" // wxMediaBackendCommonBase
116 #include "wx/msw/ole/activex.h" // wxActiveXContainer
117 #include "wx/msw/ole/automtn.h" // wxAutomationObject
118
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}};
122
123 class WXDLLIMPEXP_MEDIA wxPDFMediaBackend : public wxMediaBackendCommonBase
124 {
125 public:
126 wxPDFMediaBackend() : m_pAX(NULL) {}
127 virtual ~wxPDFMediaBackend()
128 {
129 if(m_pAX)
130 {
131 m_pAX->DissociateHandle();
132 delete m_pAX;
133 }
134 }
135 virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
136 wxWindowID id,
137 const wxPoint& pos,
138 const wxSize& size,
139 long style,
140 const wxValidator& validator,
141 const wxString& name)
142 {
143 IDispatch* pDispatch;
144 if( ::CoCreateInstance(CLSID_Pdf, NULL,
145 CLSCTX_INPROC_SERVER,
146 DIID__DPdf, (void**)&pDispatch) != 0 )
147 return false;
148
149 m_PDF.SetDispatchPtr(pDispatch); // wxAutomationObject will release itself
150
151 if ( !ctrl->wxControl::Create(parent, id, pos, size,
152 (style & ~wxBORDER_MASK) | wxBORDER_NONE,
153 validator, name) )
154 return false;
155
156 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
157 m_pAX = new wxActiveXContainer(ctrl,
158 DIID__DPdf,
159 pDispatch);
160
161 wxPDFMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE);
162 return true;
163 }
164
165 virtual bool Play()
166 {
167 return true;
168 }
169 virtual bool Pause()
170 {
171 return true;
172 }
173 virtual bool Stop()
174 {
175 return true;
176 }
177
178 virtual bool Load(const wxString& fileName)
179 {
f8ebb70d 180 if(m_PDF.CallMethod("LoadFile", fileName).GetBool())
dd72e767 181 {
f8ebb70d 182 m_PDF.CallMethod("setCurrentPage", wxVariant((long)0));
dd72e767
FM
183 NotifyMovieLoaded(); // initial refresh
184 wxSizeEvent event;
185 m_pAX->OnSize(event);
186 return true;
187 }
188
189 return false;
190 }
191 virtual bool Load(const wxURI& location)
192 {
f8ebb70d 193 return m_PDF.CallMethod("LoadFile", location.BuildUnescapedURI()).GetBool();
dd72e767
FM
194 }
195 virtual bool Load(const wxURI& WXUNUSED(location),
196 const wxURI& WXUNUSED(proxy))
197 {
198 return false;
199 }
200
201 virtual wxMediaState GetState()
202 {
203 return wxMEDIASTATE_STOPPED;
204 }
205
206 virtual bool SetPosition(wxLongLong where)
207 {
f8ebb70d 208 m_PDF.CallMethod("setCurrentPage", wxVariant((long)where.GetValue()));
dd72e767
FM
209 return true;
210 }
211 virtual wxLongLong GetPosition()
212 {
213 return 0;
214 }
215 virtual wxLongLong GetDuration()
216 {
217 return 0;
218 }
219
220 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
221 int WXUNUSED(w), int WXUNUSED(h))
222 {
223 }
224 wxSize GetVideoSize() const
225 {
226 return wxDefaultSize;
227 }
228
229 virtual double GetPlaybackRate()
230 {
231 return 0;
232 }
233 virtual bool SetPlaybackRate(double)
234 {
235 return false;
236 }
237
238 virtual double GetVolume()
239 {
240 return 0;
241 }
242 virtual bool SetVolume(double)
243 {
244 return false;
245 }
246
247 virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags)
248 {
249 if(flags)
250 {
f8ebb70d
FM
251 m_PDF.CallMethod("setShowToolbar", true);
252 m_PDF.CallMethod("setShowScrollbars", true);
dd72e767
FM
253 }
254 else
255 {
f8ebb70d
FM
256 m_PDF.CallMethod("setShowToolbar", false);
257 m_PDF.CallMethod("setShowScrollbars", false);
dd72e767
FM
258 }
259
260 return true;
261 }
262
263 wxActiveXContainer* m_pAX;
264 wxAutomationObject m_PDF;
265
b19b28c8 266 wxDECLARE_DYNAMIC_CLASS(wxPDFMediaBackend)
dd72e767
FM
267 };
268
b19b28c8
FM
269 wxIMPLEMENT_DYNAMIC_CLASS(wxPDFMediaBackend, wxMediaBackend);
270
271 // Put this in one of your existant source files and then create a wxMediaCtrl with
f8ebb70d 272 wxMediaCtrl* mymediactrl = new wxMediaCtrl(this, "myfile.pdf", wxID_ANY,
dd72e767 273 wxDefaultPosition, wxSize(300,300),
f8ebb70d 274 0, "wxPDFMediaBackend");
b19b28c8 275 // [this] is the parent window, "myfile.pdf" is the PDF file to open
dd72e767
FM
276 @endcode
277
4cc4bfaf 278
d9faa1fe
FM
279 @onlyfor{wxmsw}
280
23324ae1 281 @library{wxbase}
3c99e2fd 282 @category{ctrl,ipc}
4cc4bfaf 283
f8ebb70d 284 @see wxActiveXEvent, @ref page_samples_flash
23324ae1
FM
285*/
286class wxActiveXContainer : public wxControl
287{
288public:
289 /**
213b5041 290 Creates this ActiveX container.
d9faa1fe 291
4cc4bfaf 292 @param parent
dd72e767 293 parent of this control. Must not be @NULL.
4cc4bfaf 294 @param iid
213b5041 295 COM IID of pUnk to query. Must be a valid interface to an ActiveX control.
4cc4bfaf 296 @param pUnk
213b5041 297 Interface of ActiveX control.
23324ae1
FM
298 */
299 wxActiveXContainer(wxWindow* parent, REFIID iid, IUnknown* pUnk);
300};
e54c96f1 301