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
}\\
35 \helpref{wxWindow
}{wxwindow
}\\
36 \helpref{wxEvtHandler
}{wxevthandler
}\\
37 \helpref{wxObject
}{wxobject
}
39 \wxheading{Include files
}
41 <wx/msw/ole/activex.h>
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
}.
51 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
55 // http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACOverview.pdf
56 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
58 #include "wx/mediactrl.h" // wxMediaBackendCommonBase
59 #include "wx/msw/ole/activex.h" // wxActiveXContainer
60 #include "wx/msw/ole/automtn.h" // wxAutomationObject
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}};
66 class WXDLLIMPEXP_MEDIA wxPDFMediaBackend : public wxMediaBackendCommonBase
69 wxPDFMediaBackend() : m_pAX(NULL)
{}
70 virtual ~wxPDFMediaBackend()
74 m_pAX->DissociateHandle();
78 virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
83 const wxValidator& validator,
87 if( ::CoCreateInstance(CLSID_Pdf, NULL,
89 DIID__DPdf, (void**)&pDispatch) !=
0 )
92 m_PDF.SetDispatchPtr(pDispatch); // wxAutomationObject will release itself
94 if ( !ctrl->wxControl::Create(parent, id, pos, size,
95 (style & ~wxBORDER_MASK) | wxBORDER_NONE,
99 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
100 m_pAX = new wxActiveXContainer(ctrl,
104 wxPDFMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE);
121 virtual bool Load(const wxString& fileName)
123 if(m_PDF.CallMethod(wxT("LoadFile"), fileName).GetBool())
125 m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)
0));
126 NotifyMovieLoaded(); // initial refresh
128 m_pAX->OnSize(event);
134 virtual bool Load(const wxURI& location)
136 return m_PDF.CallMethod(wxT("LoadFile"), location.BuildUnescapedURI()).GetBool();
138 virtual bool Load(const wxURI& WXUNUSED(location),
139 const wxURI& WXUNUSED(proxy))
144 virtual wxMediaState GetState()
146 return wxMEDIASTATE_STOPPED;
149 virtual bool SetPosition(wxLongLong where)
151 m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)where.GetValue()));
154 virtual wxLongLong GetPosition()
158 virtual wxLongLong GetDuration()
163 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
164 int WXUNUSED(w), int WXUNUSED(h))
167 wxSize GetVideoSize() const
169 return wxDefaultSize;
172 virtual double GetPlaybackRate()
176 virtual bool SetPlaybackRate(double)
181 virtual double GetVolume()
185 virtual bool SetVolume(double)
190 virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags)
194 m_PDF.CallMethod(wxT("setShowToolbar"), true);
195 m_PDF.CallMethod(wxT("setShowScrollbars"), true);
199 m_PDF.CallMethod(wxT("setShowToolbar"), false);
200 m_PDF.CallMethod(wxT("setShowScrollbars"), false);
206 wxActiveXContainer* m_pAX;
207 wxAutomationObject m_PDF;
209 DECLARE_DYNAMIC_CLASS(wxPDFMediaBackend)
212 IMPLEMENT_DYNAMIC_CLASS(wxPDFMediaBackend, wxMediaBackend);
215 Put this in one of your existant source files and then create a wxMediaCtrl with
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"));
224 \latexignore{\rtfignore{\wxheading{Members
}}}
226 \membersection{wxActiveXContainer::wxActiveXContainer
}\label{wxactivexcontainerwxactivexcontainer
}
228 \func{}{wxActiveXContainer
}{
229 \param{wxWindow*
}{parent
},
230 \param{REFIID
}{iid
},
231 \param{IUnknown*
}{pUnk
},
234 Creates this activex container.
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
}