]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/activexcontainer.tex
added new and improved wxFileCtrl implementation (patch 1763164)
[wxWidgets.git] / docs / latex / wx / activexcontainer.tex
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %% Name: activexcontainer.tex
3 %% Purpose: wxActiveXContainer docs
4 %% Author: Ryan Norton <wxprojects@comcast.net>
5 %% Modified by:
6 %% Created: 01/30/2005
7 %% RCS-ID: $Id$
8 %% Copyright: (c) Ryan Norton
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12 \section{\class{wxActiveXContainer}}\label{wxactivexcontainer}
13
14 wxActiveXContainer is a host for an activex control on Windows (and
15 as such is a platform-specific class). Note that the HWND that the class
16 contains is the actual HWND of the activex control so using dynamic events
17 and connecting to wxEVT\_SIZE, for example, will recieve the actual size
18 message sent to the control.
19
20 It is somewhat similar to the ATL class CAxWindow in operation.
21
22 The size of the activex control's content is generally gauranteed to be that
23 of the client size of the parent of this wxActiveXContainer.
24
25 You can also process activex events through wxEVT\_ACTIVEX or the
26 corresponding message map macro EVT\_ACTIVEX.
27
28 \wxheading{See also}
29
30 \helpref{wxActiveXEvent}{wxactivexevent}
31
32 \wxheading{Derived from}
33
34 \helpref{wxControl}{wxcontrol}\\
35 \helpref{wxWindow}{wxwindow}\\
36 \helpref{wxEvtHandler}{wxevthandler}\\
37 \helpref{wxObject}{wxobject}
38
39 \wxheading{Include files}
40
41 <wx/msw/ole/activex.h>
42
43 \wxheading{Example}
44
45 This is an example of how to use the Adobe Acrobat Reader ActiveX control to read PDF files
46 (requires Acrobat Reader 4 and up). Controls like this are typically found and dumped from
47 OLEVIEW.exe that is distributed with Microsoft Visual C++. This example also demonstrates
48 how to create a backend for \helpref{wxMediaCtrl}{wxmediactrl}.
49
50 \begin{verbatim}
51 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
52 //
53 // wxPDFMediaBackend
54 //
55 // http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACOverview.pdf
56 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
57
58 #include "wx/mediactrl.h" // wxMediaBackendCommonBase
59 #include "wx/msw/ole/activex.h" // wxActiveXContainer
60 #include "wx/msw/ole/automtn.h" // wxAutomationObject
61
62 const IID DIID__DPdf = {0xCA8A9781,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
63 const IID DIID__DPdfEvents = {0xCA8A9782,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
64 const CLSID CLSID_Pdf = {0xCA8A9780,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
65
66 class WXDLLIMPEXP_MEDIA wxPDFMediaBackend : public wxMediaBackendCommonBase
67 {
68 public:
69 wxPDFMediaBackend() : m_pAX(NULL) {}
70 virtual ~wxPDFMediaBackend()
71 {
72 if(m_pAX)
73 {
74 m_pAX->DissociateHandle();
75 delete m_pAX;
76 }
77 }
78 virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
79 wxWindowID id,
80 const wxPoint& pos,
81 const wxSize& size,
82 long style,
83 const wxValidator& validator,
84 const wxString& name)
85 {
86 IDispatch* pDispatch;
87 if( ::CoCreateInstance(CLSID_Pdf, NULL,
88 CLSCTX_INPROC_SERVER,
89 DIID__DPdf, (void**)&pDispatch) != 0 )
90 return false;
91
92 m_PDF.SetDispatchPtr(pDispatch); // wxAutomationObject will release itself
93
94 if ( !ctrl->wxControl::Create(parent, id, pos, size,
95 (style & ~wxBORDER_MASK) | wxBORDER_NONE,
96 validator, name) )
97 return false;
98
99 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
100 m_pAX = new wxActiveXContainer(ctrl,
101 DIID__DPdf,
102 pDispatch);
103
104 wxPDFMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE);
105 return true;
106 }
107
108 virtual bool Play()
109 {
110 return true;
111 }
112 virtual bool Pause()
113 {
114 return true;
115 }
116 virtual bool Stop()
117 {
118 return true;
119 }
120
121 virtual bool Load(const wxString& fileName)
122 {
123 if(m_PDF.CallMethod(wxT("LoadFile"), fileName).GetBool())
124 {
125 m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)0));
126 NotifyMovieLoaded(); // initial refresh
127 wxSizeEvent event;
128 m_pAX->OnSize(event);
129 return true;
130 }
131
132 return false;
133 }
134 virtual bool Load(const wxURI& location)
135 {
136 return m_PDF.CallMethod(wxT("LoadFile"), location.BuildUnescapedURI()).GetBool();
137 }
138 virtual bool Load(const wxURI& WXUNUSED(location),
139 const wxURI& WXUNUSED(proxy))
140 {
141 return false;
142 }
143
144 virtual wxMediaState GetState()
145 {
146 return wxMEDIASTATE_STOPPED;
147 }
148
149 virtual bool SetPosition(wxLongLong where)
150 {
151 m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)where.GetValue()));
152 return true;
153 }
154 virtual wxLongLong GetPosition()
155 {
156 return 0;
157 }
158 virtual wxLongLong GetDuration()
159 {
160 return 0;
161 }
162
163 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
164 int WXUNUSED(w), int WXUNUSED(h))
165 {
166 }
167 wxSize GetVideoSize() const
168 {
169 return wxDefaultSize;
170 }
171
172 virtual double GetPlaybackRate()
173 {
174 return 0;
175 }
176 virtual bool SetPlaybackRate(double)
177 {
178 return false;
179 }
180
181 virtual double GetVolume()
182 {
183 return 0;
184 }
185 virtual bool SetVolume(double)
186 {
187 return false;
188 }
189
190 virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags)
191 {
192 if(flags)
193 {
194 m_PDF.CallMethod(wxT("setShowToolbar"), true);
195 m_PDF.CallMethod(wxT("setShowScrollbars"), true);
196 }
197 else
198 {
199 m_PDF.CallMethod(wxT("setShowToolbar"), false);
200 m_PDF.CallMethod(wxT("setShowScrollbars"), false);
201 }
202
203 return true;
204 }
205
206 wxActiveXContainer* m_pAX;
207 wxAutomationObject m_PDF;
208
209 DECLARE_DYNAMIC_CLASS(wxPDFMediaBackend)
210 };
211
212 IMPLEMENT_DYNAMIC_CLASS(wxPDFMediaBackend, wxMediaBackend);
213 \end{verbatim}
214
215 Put this in one of your existant source files and then create a wxMediaCtrl with
216 \begin{verbatim}
217 //[this] is the parent window, "myfile.pdf" is the PDF file to open
218 wxMediaCtrl* mymediactrl = new wxMediaCtrl(this, wxT("myfile.pdf"), wxID_ANY,
219 wxDefaultPosition, wxSize(300,300),
220 0, wxT("wxPDFMediaBackend"));
221 \end{verbatim}
222
223
224 \latexignore{\rtfignore{\wxheading{Members}}}
225
226 \membersection{wxActiveXContainer::wxActiveXContainer}\label{wxactivexcontainerwxactivexcontainer}
227
228 \func{}{wxActiveXContainer}{
229 \param{wxWindow* }{parent},
230 \param{REFIID }{iid},
231 \param{IUnknown* }{pUnk},
232 }
233
234 Creates this activex container.
235
236 \docparam{parent}{parent of this control. Must not be NULL.}
237 \docparam{iid}{COM IID of pUnk to query. Must be a valid interface to an activex control.}
238 \docparam{pUnk}{Interface of activex control}
239