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