]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/msw/ole/activex.h
579522e088feb36ebb57d04af2fd2f7629ebc745
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 Note that unlike the third party wxActiveX function names are not supported.
21 @beginEventTable{wxActiveXEvent}
22 @event{EVT_ACTIVEX(func)}
23 Sent when the activex control hosted by wxActiveXContainer recieves an
32 class wxActiveXEvent
: public wxCommandEvent
36 Returns the dispatch id of this activex event.
37 This is the numeric value from the .idl file specified by the id().
39 DISPID
GetDispatchId(int idx
) const;
42 Obtains the number of parameters passed through the activex event.
44 size_t ParamCount() const;
47 Obtains the param name of the param number idx specifies as a string.
49 wxString
ParamName(size_t idx
) const;
52 Obtains the param type of the param number idx specifies as a string.
54 wxString
ParamType(size_t idx
) const;
57 Obtains the actual parameter value specified by idx.
59 wxVariant
operator[](size_t idx
);
65 @class wxActiveXContainer
67 wxActiveXContainer is a host for an activex control on Windows (and as such
68 is a platform-specific class).
70 Note that the HWND that the class contains is the actual HWND of the activeX
71 control so using dynamic events and connecting to wxEVT_SIZE, for example,
72 will recieve the actual size message sent to the control.
74 It is somewhat similar to the ATL class CAxWindow in operation.
76 The size of the activex control's content is generally gauranteed to be that
77 of the client size of the parent of this wxActiveXContainer.
79 You can also process activeX events through wxActiveXEvent.
82 @section activexcontainer_example Example
84 This is an example of how to use the Adobe Acrobat Reader ActiveX control to
85 read PDF files (requires Acrobat Reader 4 and up).
86 Controls like this are typically found and dumped from OLEVIEW.exe that is
87 distributed with Microsoft Visual C++.
88 This example also demonstrates how to create a backend for wxMediaCtrl.
91 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
95 // http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACOverview.pdf
96 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
98 #include "wx/mediactrl.h" // wxMediaBackendCommonBase
99 #include "wx/msw/ole/activex.h" // wxActiveXContainer
100 #include "wx/msw/ole/automtn.h" // wxAutomationObject
102 const IID DIID__DPdf = {0xCA8A9781,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
103 const IID DIID__DPdfEvents = {0xCA8A9782,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
104 const CLSID CLSID_Pdf = {0xCA8A9780,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
106 class WXDLLIMPEXP_MEDIA wxPDFMediaBackend : public wxMediaBackendCommonBase
109 wxPDFMediaBackend() : m_pAX(NULL) {}
110 virtual ~wxPDFMediaBackend()
114 m_pAX->DissociateHandle();
118 virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
123 const wxValidator& validator,
124 const wxString& name)
126 IDispatch* pDispatch;
127 if( ::CoCreateInstance(CLSID_Pdf, NULL,
128 CLSCTX_INPROC_SERVER,
129 DIID__DPdf, (void**)&pDispatch) != 0 )
132 m_PDF.SetDispatchPtr(pDispatch); // wxAutomationObject will release itself
134 if ( !ctrl->wxControl::Create(parent, id, pos, size,
135 (style & ~wxBORDER_MASK) | wxBORDER_NONE,
139 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
140 m_pAX = new wxActiveXContainer(ctrl,
144 wxPDFMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE);
161 virtual bool Load(const wxString& fileName)
163 if(m_PDF.CallMethod(wxT("LoadFile"), fileName).GetBool())
165 m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)0));
166 NotifyMovieLoaded(); // initial refresh
168 m_pAX->OnSize(event);
174 virtual bool Load(const wxURI& location)
176 return m_PDF.CallMethod(wxT("LoadFile"), location.BuildUnescapedURI()).GetBool();
178 virtual bool Load(const wxURI& WXUNUSED(location),
179 const wxURI& WXUNUSED(proxy))
184 virtual wxMediaState GetState()
186 return wxMEDIASTATE_STOPPED;
189 virtual bool SetPosition(wxLongLong where)
191 m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)where.GetValue()));
194 virtual wxLongLong GetPosition()
198 virtual wxLongLong GetDuration()
203 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
204 int WXUNUSED(w), int WXUNUSED(h))
207 wxSize GetVideoSize() const
209 return wxDefaultSize;
212 virtual double GetPlaybackRate()
216 virtual bool SetPlaybackRate(double)
221 virtual double GetVolume()
225 virtual bool SetVolume(double)
230 virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags)
234 m_PDF.CallMethod(wxT("setShowToolbar"), true);
235 m_PDF.CallMethod(wxT("setShowScrollbars"), true);
239 m_PDF.CallMethod(wxT("setShowToolbar"), false);
240 m_PDF.CallMethod(wxT("setShowScrollbars"), false);
246 wxActiveXContainer* m_pAX;
247 wxAutomationObject m_PDF;
249 DECLARE_DYNAMIC_CLASS(wxPDFMediaBackend)
252 IMPLEMENT_DYNAMIC_CLASS(wxPDFMediaBackend, wxMediaBackend);
253 Put this in one of your existant source files and then create a wxMediaCtrl with
255 //[this] is the parent window, "myfile.pdf" is the PDF file to open
256 wxMediaCtrl* mymediactrl = new wxMediaCtrl(this, wxT("myfile.pdf"), wxID_ANY,
257 wxDefaultPosition, wxSize(300,300),
258 0, wxT("wxPDFMediaBackend"));
269 class wxActiveXContainer
: public wxControl
273 Creates this activex container.
276 parent of this control. Must not be @NULL.
278 COM IID of pUnk to query. Must be a valid interface to an activex control.
280 Interface of activex control.
282 wxActiveXContainer(wxWindow
* parent
, REFIID iid
, IUnknown
* pUnk
);