]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/activexcontainer.tex
remove gettext docs, they have nothing to do in our cvs (see patch 1713939)
[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
36 \wxheading{Include files}
37
38 <wx/msw/ole/activex.h>
39
40 \wxheading{Example}
41
42 This is an example of how to use the Adobe Acrobat Reader ActiveX control to read PDF files
43 (requires Acrobat Reader 4 and up). Controls like this are typically found and dumped from
44 OLEVIEW.exe that is distributed with Microsoft Visual C++. This example also demonstrates
45 how to create a backend for \helpref{wxMediaCtrl}{wxmediactrl}.
46
47 \begin{verbatim}
48 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
49 //
50 // wxPDFMediaBackend
51 //
52 // http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACOverview.pdf
53 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
54
55 #include "wx/mediactrl.h" // wxMediaBackendCommonBase
56 #include "wx/msw/ole/activex.h" // wxActiveXContainer
57 #include "wx/msw/ole/automtn.h" // wxAutomationObject
58
59 const IID DIID__DPdf = {0xCA8A9781,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
60 const IID DIID__DPdfEvents = {0xCA8A9782,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
61 const CLSID CLSID_Pdf = {0xCA8A9780,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
62
63 class WXDLLIMPEXP_MEDIA wxPDFMediaBackend : public wxMediaBackendCommonBase
64 {
65 public:
66 wxPDFMediaBackend() : m_pAX(NULL) {}
67 virtual ~wxPDFMediaBackend()
68 {
69 if(m_pAX)
70 {
71 m_pAX->DissociateHandle();
72 delete m_pAX;
73 }
74 }
75 virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
76 wxWindowID id,
77 const wxPoint& pos,
78 const wxSize& size,
79 long style,
80 const wxValidator& validator,
81 const wxString& name)
82 {
83 IDispatch* pDispatch;
84 if( ::CoCreateInstance(CLSID_Pdf, NULL,
85 CLSCTX_INPROC_SERVER,
86 DIID__DPdf, (void**)&pDispatch) != 0 )
87 return false;
88
89 m_PDF.SetDispatchPtr(pDispatch); // wxAutomationObject will release itself
90
91 if ( !ctrl->wxControl::Create(parent, id, pos, size,
92 (style & ~wxBORDER_MASK) | wxBORDER_NONE,
93 validator, name) )
94 return false;
95
96 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
97 m_pAX = new wxActiveXContainer(ctrl,
98 DIID__DPdf,
99 pDispatch);
100
101 wxPDFMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE);
102 return true;
103 }
104
105 virtual bool Play()
106 {
107 return true;
108 }
109 virtual bool Pause()
110 {
111 return true;
112 }
113 virtual bool Stop()
114 {
115 return true;
116 }
117
118 virtual bool Load(const wxString& fileName)
119 {
120 if(m_PDF.CallMethod(wxT("LoadFile"), fileName).GetBool())
121 {
122 m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)0));
123 NotifyMovieLoaded(); // initial refresh
124 wxSizeEvent event;
125 m_pAX->OnSize(event);
126 return true;
127 }
128
129 return false;
130 }
131 virtual bool Load(const wxURI& location)
132 {
133 return m_PDF.CallMethod(wxT("LoadFile"), location.BuildUnescapedURI()).GetBool();
134 }
135 virtual bool Load(const wxURI& WXUNUSED(location),
136 const wxURI& WXUNUSED(proxy))
137 {
138 return false;
139 }
140
141 virtual wxMediaState GetState()
142 {
143 return wxMEDIASTATE_STOPPED;
144 }
145
146 virtual bool SetPosition(wxLongLong where)
147 {
148 m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)where.GetValue()));
149 return true;
150 }
151 virtual wxLongLong GetPosition()
152 {
153 return 0;
154 }
155 virtual wxLongLong GetDuration()
156 {
157 return 0;
158 }
159
160 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
161 int WXUNUSED(w), int WXUNUSED(h))
162 {
163 }
164 wxSize GetVideoSize() const
165 {
166 return wxDefaultSize;
167 }
168
169 virtual double GetPlaybackRate()
170 {
171 return 0;
172 }
173 virtual bool SetPlaybackRate(double)
174 {
175 return false;
176 }
177
178 virtual double GetVolume()
179 {
180 return 0;
181 }
182 virtual bool SetVolume(double)
183 {
184 return false;
185 }
186
187 virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags)
188 {
189 if(flags)
190 {
191 m_PDF.CallMethod(wxT("setShowToolbar"), true);
192 m_PDF.CallMethod(wxT("setShowScrollbars"), true);
193 }
194 else
195 {
196 m_PDF.CallMethod(wxT("setShowToolbar"), false);
197 m_PDF.CallMethod(wxT("setShowScrollbars"), false);
198 }
199
200 return true;
201 }
202
203 wxActiveXContainer* m_pAX;
204 wxAutomationObject m_PDF;
205
206 DECLARE_DYNAMIC_CLASS(wxPDFMediaBackend)
207 };
208
209 IMPLEMENT_DYNAMIC_CLASS(wxPDFMediaBackend, wxMediaBackend);
210 \end{verbatim}
211
212 Put this in one of your existant source files and then create a wxMediaCtrl with
213 \begin{verbatim}
214 //[this] is the parent window, "myfile.pdf" is the PDF file to open
215 wxMediaCtrl* mymediactrl = new wxMediaCtrl(this, wxT("myfile.pdf"), wxID_ANY,
216 wxDefaultPosition, wxSize(300,300),
217 0, wxT("wxPDFMediaBackend"));
218 \end{verbatim}
219
220
221 \latexignore{\rtfignore{\wxheading{Members}}}
222
223 \membersection{wxActiveXContainer::wxActiveXContainer}\label{wxactivexcontainerwxactivexcontainer}
224
225 \func{}{wxActiveXContainer}{
226 \param{wxWindow* }{parent},
227 \param{REFIID }{iid},
228 \param{IUnknown* }{pUnk},
229 }
230
231 Creates this activex container.
232
233 \docparam{parent}{parent of this control. Must not be NULL.}
234 \docparam{iid}{COM IID of pUnk to query. Must be a valid interface to an activex control.}
235 \docparam{pUnk}{Interface of activex control}
236