File: activexcontainer.tex

package info (click to toggle)
wxwidgets2.8 2.8.12.1-12
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 242,920 kB
  • sloc: cpp: 1,840,772; xml: 385,749; python: 334,729; makefile: 51,774; ansic: 30,987; sh: 7,716; sql: 258; lex: 194; perl: 139; yacc: 128; pascal: 95; php: 45; lisp: 38; tcl: 38; java: 22; haskell: 20; cs: 18; erlang: 17; ruby: 16; asm: 15; ada: 9; ml: 9; csh: 9
file content (236 lines) | stat: -rw-r--r-- 7,185 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name:        activexcontainer.tex
%% Purpose:     wxActiveXContainer docs
%% Author:      Ryan Norton <wxprojects@comcast.net>
%% Modified by:
%% Created:     01/30/2005
%% RCS-ID:      $Id: activexcontainer.tex 37461 2006-02-10 19:37:40Z VZ $
%% Copyright:   (c) Ryan Norton
%% License:     wxWindows license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{\class{wxActiveXContainer}}\label{wxactivexcontainer}

wxActiveXContainer is a host for an activex control on Windows (and
as such is a platform-specific class). Note that the HWND that the class
contains is the actual HWND of the activex control so using dynamic events
and connecting to wxEVT\_SIZE, for example, will recieve the actual size
message sent to the control.

It is somewhat similar to the ATL class CAxWindow in operation.

The size of the activex control's content is generally gauranteed to be that
of the client size of the parent of this wxActiveXContainer.

You can also process activex events through wxEVT\_ACTIVEX or the
corresponding message map macro EVT\_ACTIVEX.

\wxheading{See also}

\helpref{wxActiveXEvent}{wxactivexevent}

\wxheading{Derived from}

\helpref{wxControl}{wxcontrol}

\wxheading{Include files}

<wx/msw/ole/activex.h>

\wxheading{Example}

This is an example of how to use the Adobe Acrobat Reader ActiveX control to read PDF files
(requires Acrobat Reader 4 and up). Controls like this are typically found and dumped from
OLEVIEW.exe that is distributed with Microsoft Visual C++. This example also demonstrates
how to create a backend for \helpref{wxMediaCtrl}{wxmediactrl}.

\begin{verbatim}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// wxPDFMediaBackend
//
// http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACOverview.pdf
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#include "wx/mediactrl.h"       // wxMediaBackendCommonBase
#include "wx/msw/ole/activex.h" // wxActiveXContainer
#include "wx/msw/ole/automtn.h" // wxAutomationObject

const IID DIID__DPdf = {0xCA8A9781,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
const IID DIID__DPdfEvents = {0xCA8A9782,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};
const CLSID CLSID_Pdf = {0xCA8A9780,0x280D,0x11CF,{0xA2,0x4D,0x44,0x45,0x53,0x54,0x00,0x00}};

class WXDLLIMPEXP_MEDIA wxPDFMediaBackend : public wxMediaBackendCommonBase
{
public:
    wxPDFMediaBackend() : m_pAX(NULL) {}
    virtual ~wxPDFMediaBackend()
    {
        if(m_pAX)
        {
            m_pAX->DissociateHandle();
            delete m_pAX;
        }
    }
    virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
                                     wxWindowID id,
                                     const wxPoint& pos,
                                     const wxSize& size,
                                     long style,
                                     const wxValidator& validator,
                                     const wxString& name)
    {
        IDispatch* pDispatch;
        if( ::CoCreateInstance(CLSID_Pdf, NULL,
                                  CLSCTX_INPROC_SERVER,
                                  DIID__DPdf, (void**)&pDispatch) != 0 )
            return false;

        m_PDF.SetDispatchPtr(pDispatch); // wxAutomationObject will release itself

        if ( !ctrl->wxControl::Create(parent, id, pos, size,
                                (style & ~wxBORDER_MASK) | wxBORDER_NONE,
                                validator, name) )
            return false;

        m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
        m_pAX = new wxActiveXContainer(ctrl,
                    DIID__DPdf,
                    pDispatch);

        wxPDFMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE);
        return true;
    }

    virtual bool Play()
    {
        return true;
    }
    virtual bool Pause()
    {
        return true;
    }
    virtual bool Stop()
    {
        return true;
    }

    virtual bool Load(const wxString& fileName)
    {
        if(m_PDF.CallMethod(wxT("LoadFile"), fileName).GetBool())
        {
            m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)0));
            NotifyMovieLoaded(); // initial refresh
            wxSizeEvent event;
            m_pAX->OnSize(event);
            return true;
        }

        return false;
    }
    virtual bool Load(const wxURI& location)
    {
        return m_PDF.CallMethod(wxT("LoadFile"), location.BuildUnescapedURI()).GetBool();
    }
    virtual bool Load(const wxURI& WXUNUSED(location),
                      const wxURI& WXUNUSED(proxy))
    {
        return false;
    }

    virtual wxMediaState GetState()
    {
        return wxMEDIASTATE_STOPPED;
    }

    virtual bool SetPosition(wxLongLong where)
    {
        m_PDF.CallMethod(wxT("setCurrentPage"), wxVariant((long)where.GetValue()));
        return true;
    }
    virtual wxLongLong GetPosition()
    {
        return 0;
    }
    virtual wxLongLong GetDuration()
    {
        return 0;
    }

    virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
                      int WXUNUSED(w), int WXUNUSED(h))
    {
    }
    wxSize GetVideoSize() const
    {
        return wxDefaultSize;
    }

    virtual double GetPlaybackRate()
    {
        return 0;
    }
    virtual bool SetPlaybackRate(double)
    {
        return false;
    }

    virtual double GetVolume()
    {
        return 0;
    }
    virtual bool SetVolume(double)
    {
        return false;
    }

    virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags)
    {
        if(flags)
        {
            m_PDF.CallMethod(wxT("setShowToolbar"), true);
            m_PDF.CallMethod(wxT("setShowScrollbars"), true);
        }
        else
        {
            m_PDF.CallMethod(wxT("setShowToolbar"), false);
            m_PDF.CallMethod(wxT("setShowScrollbars"), false);
        }

        return true;
    }

    wxActiveXContainer* m_pAX;
    wxAutomationObject m_PDF;

    DECLARE_DYNAMIC_CLASS(wxPDFMediaBackend)
};

IMPLEMENT_DYNAMIC_CLASS(wxPDFMediaBackend, wxMediaBackend);
\end{verbatim}

Put this in one of your existant source files and then create a wxMediaCtrl with
\begin{verbatim}
//[this] is the parent window, "myfile.pdf" is the PDF file to open
wxMediaCtrl* mymediactrl = new wxMediaCtrl(this, wxT("myfile.pdf"), wxID_ANY,
                                           wxDefaultPosition, wxSize(300,300),
                                           0, wxT("wxPDFMediaBackend"));
\end{verbatim}


\latexignore{\rtfignore{\wxheading{Members}}}

\membersection{wxActiveXContainer::wxActiveXContainer}\label{wxactivexcontainerwxactivexcontainer}

\func{}{wxActiveXContainer}{
        \param{wxWindow* }{parent},
        \param{REFIID }{iid},
        \param{IUnknown* }{pUnk},
                   }

Creates this activex container.

\docparam{parent}{parent of this control.  Must not be NULL.}
\docparam{iid}{COM IID of pUnk to query. Must be a valid interface to an activex control.}
\docparam{pUnk}{Interface of activex control}