1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %% Name: activexcontainer.tex
3 %% Purpose: wxActiveXContainer docs
4 %% Author: Ryan Norton <wxprojects@comcast.net>
8 %% Copyright: (c) Ryan Norton
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxActiveXContainer
}}\label{wxactivexcontainer
}
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.
20 It is somewhat similar to the ATL class CAxWindow in operation.
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.
25 You can also process activex events through wxEVT
\_ACTIVEX or the
26 corresponding message map macro EVT
\_ACTIVEX.
30 \helpref{wxActiveXEvent
}{wxactivexevent
}
32 \wxheading{Derived from
}
34 \helpref{wxControl
}{wxcontrol
}
36 \wxheading{Include files
}
38 <wx/msw/ole/activex.h>
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
}.
48 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
52 // http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACOverview.pdf
53 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
55 #include "wx/mediactrl.h" // wxMediaBackendCommonBase
56 #include "wx/msw/ole/activex.h" // wxActiveXContainer
57 #include "wx/msw/ole/automtn.h" // wxAutomationObject
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}};
63 class WXDLLIMPEXP_MEDIA wxPDFMediaBackend : public wxMediaBackendCommonBase
66 wxPDFMediaBackend() : m_pAX(NULL)
{}
67 virtual ~wxPDFMediaBackend()
71 m_pAX->DissociateHandle();
75 virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
80 const wxValidator& validator,
84 if( ::CoCreateInstance(CLSID_Pdf, NULL,
86 DIID__DPdf, (void**)&pDispatch) !=
0 )
89 m_PDF.SetDispatchPtr(pDispatch); // wxAutomationObject will release itself
91 if ( !ctrl->wxControl::Create(parent, id, pos, size,
92 (style & ~wxBORDER_MASK) | wxBORDER_NONE,
96 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
97 m_pAX = new wxActiveXContainer(ctrl,
101 wxPDFMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE);
118 virtual bool Load(const wxString& fileName)
120 if(m_PDF.CallMethod(wxT("LoadFile"), fileName).GetBool())
122 m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)
0));
123 NotifyMovieLoaded(); // initial refresh
125 m_pAX->OnSize(event);
131 virtual bool Load(const wxURI& location)
133 return m_PDF.CallMethod(wxT("LoadFile"), location.BuildUnescapedURI()).GetBool();
135 virtual bool Load(const wxURI& WXUNUSED(location),
136 const wxURI& WXUNUSED(proxy))
141 virtual wxMediaState GetState()
143 return wxMEDIASTATE_STOPPED;
146 virtual bool SetPosition(wxLongLong where)
148 m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)where.GetValue()));
151 virtual wxLongLong GetPosition()
155 virtual wxLongLong GetDuration()
160 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
161 int WXUNUSED(w), int WXUNUSED(h))
164 wxSize GetVideoSize() const
166 return wxDefaultSize;
169 virtual double GetPlaybackRate()
173 virtual bool SetPlaybackRate(double)
178 virtual double GetVolume()
182 virtual bool SetVolume(double)
187 virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags)
191 m_PDF.CallMethod(wxT("setShowToolbar"), true);
192 m_PDF.CallMethod(wxT("setShowScrollbars"), true);
196 m_PDF.CallMethod(wxT("setShowToolbar"), false);
197 m_PDF.CallMethod(wxT("setShowScrollbars"), false);
203 wxActiveXContainer* m_pAX;
204 wxAutomationObject m_PDF;
206 DECLARE_DYNAMIC_CLASS(wxPDFMediaBackend)
209 IMPLEMENT_DYNAMIC_CLASS(wxPDFMediaBackend, wxMediaBackend);
212 Put this in one of your existant source files and then create a wxMediaCtrl with
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"));
221 \latexignore{\rtfignore{\wxheading{Members
}}}
223 \membersection{wxActiveXContainer::wxActiveXContainer
}\label{wxactivexcontainerwxactivexcontainer
}
225 \func{}{wxActiveXContainer
}{
226 \param{wxWindow*
}{parent
},
227 \param{REFIID
}{iid
},
228 \param{IUnknown*
}{pUnk
},
231 Creates this activex container.
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
}