|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the documentation of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 //! [0] |
|
43 TEMPLATE = app |
|
44 CONFIG += qaxserver |
|
45 |
|
46 RC_FILE = qaxserver.rc |
|
47 ... |
|
48 //! [0] |
|
49 |
|
50 |
|
51 //! [1] |
|
52 TEMPLATE = lib |
|
53 CONFIG += qaxserver dll |
|
54 |
|
55 DEF_FILE = qaxserver.def |
|
56 RC_FILE = qaxserver.rc |
|
57 ... |
|
58 //! [1] |
|
59 |
|
60 |
|
61 //! [2] |
|
62 TEMPLATE = lib |
|
63 VERSION = 2.5 |
|
64 ... |
|
65 //! [2] |
|
66 |
|
67 |
|
68 //! [3] |
|
69 #include <QWidget> |
|
70 |
|
71 class MyActiveX : public QWidget |
|
72 { |
|
73 Q_OBJECT |
|
74 //! [3] |
|
75 |
|
76 |
|
77 //! [4] |
|
78 Q_CLASSINFO("ClassID", "{1D9928BD-4453-4bdd-903D-E525ED17FDE5}") |
|
79 Q_CLASSINFO("InterfaceID", "{99F6860E-2C5A-42ec-87F2-43396F4BE389}") |
|
80 Q_CLASSINFO("EventsID", "{0A3E9F27-E4F1-45bb-9E47-63099BCCD0E3}") |
|
81 //! [4] |
|
82 |
|
83 |
|
84 //! [5] |
|
85 Q_PROPERTY(int value READ value WRITE setValue) |
|
86 //! [5] |
|
87 |
|
88 |
|
89 //! [6] |
|
90 public: |
|
91 MyActiveX(QWidget *parent = 0) |
|
92 ... |
|
93 |
|
94 int value() const; |
|
95 |
|
96 public slots: |
|
97 void setValue(int v); |
|
98 ... |
|
99 |
|
100 signals: |
|
101 void valueChange(int v); |
|
102 ... |
|
103 |
|
104 }; |
|
105 //! [6] |
|
106 |
|
107 |
|
108 //! [7] |
|
109 #include <QAxBindable> |
|
110 #include <QWidget> |
|
111 |
|
112 class MyActiveX : public QWidget, public QAxBindable |
|
113 { |
|
114 Q_OBJECT |
|
115 //! [7] |
|
116 |
|
117 |
|
118 //! [8] |
|
119 QAXFACTORY_BEGIN("{ad90301a-849e-4e8b-9a91-0a6dc5f6461f}", |
|
120 "{a8f21901-7ff7-4f6a-b939-789620c03d83}") |
|
121 QAXCLASS(MyWidget) |
|
122 QAXCLASS(MyWidget2) |
|
123 QAXTYPE(MySubType) |
|
124 QAXFACTORY_END() |
|
125 //! [8] |
|
126 |
|
127 |
|
128 //! [9] |
|
129 #include <QApplication> |
|
130 #include <QAxFactory> |
|
131 |
|
132 int main(int argc, char *argv[]) |
|
133 { |
|
134 QApplication app(argc, argv); |
|
135 if (!QAxFactory::isServer()) { |
|
136 // create and show main window |
|
137 } |
|
138 return app.exec(); |
|
139 } |
|
140 //! [9] |
|
141 |
|
142 |
|
143 //! [10] |
|
144 MyFactory(const QUuid &, const QUuid &); |
|
145 //! [10] |
|
146 |
|
147 |
|
148 //! [11] |
|
149 HMODULE dll = LoadLibrary("myserver.dll"); |
|
150 typedef HRESULT(__stdcall *DllRegisterServerProc)(); |
|
151 DllRegisterServerProc DllRegisterServer = |
|
152 (DllRegisterServerProc)GetProcAddress(dll, "DllRegisterServer"); |
|
153 |
|
154 HRESULT res = E_FAIL; |
|
155 if (DllRegisterServer) |
|
156 res = DllRegisterServer(); |
|
157 if (res != S_OK) |
|
158 // error handling |
|
159 //! [11] |
|
160 |
|
161 |
|
162 //! [12] |
|
163 cabarc N simpleax.cab simpleax.exe simple.inf |
|
164 //! [12] |
|
165 |
|
166 |
|
167 //! [13] |
|
168 <object ID="MyActiveX1" CLASSID="CLSID:ad90301a-849e-4e8b-9a91-0a6dc5f6461f"> |
|
169 ... |
|
170 <\object> |
|
171 //! [13] |
|
172 |
|
173 |
|
174 //! [14] |
|
175 <object ID=...> |
|
176 <param name="name" value="value"> |
|
177 <\object> |
|
178 //! [14] |
|
179 |
|
180 |
|
181 //! [15] |
|
182 class MyActiveX : public QWidget |
|
183 { |
|
184 Q_OBJECT |
|
185 Q_CLASSINFO("Version", "2.0") |
|
186 Q_CLASSINFO("ClassID", "{7a4cffd8-cbcd-4ae9-ae7e-343e1e5710df}") |
|
187 Q_CLASSINFO("InterfaceID", "{6fb035bf-8019-48d8-be51-ef05427d8994}") |
|
188 Q_CLASSINFO("EventsID", "{c42fffdf-6557-47c9-817a-2da2228bc29c}") |
|
189 Q_CLASSINFO("Insertable", "yes") |
|
190 Q_CLASSINFO("ToSuperClass", "MyActiveX") |
|
191 Q_PROPERTY(...) |
|
192 |
|
193 public: |
|
194 MyActiveX(QWidget *parent = 0); |
|
195 |
|
196 ... |
|
197 }; |
|
198 //! [15] |
|
199 |
|
200 |
|
201 //! [16] |
|
202 class MyLicensedControl : public QWidget |
|
203 { |
|
204 Q_OBJECT |
|
205 Q_CLASSINFO("LicenseKey", "<key string>") |
|
206 ... |
|
207 }; |
|
208 //! [16] |
|
209 |
|
210 |
|
211 //! [17] |
|
212 class AxImpl : public QAxAggregated, public ISomeCOMInterface |
|
213 { |
|
214 public: |
|
215 AxImpl() {} |
|
216 |
|
217 long queryInterface(const QUuid &iid, void **iface); |
|
218 |
|
219 // IUnknown |
|
220 QAXAGG_IUNKNOWN |
|
221 |
|
222 // ISomeCOMInterface |
|
223 ... |
|
224 } |
|
225 //! [17] |
|
226 |
|
227 |
|
228 //! [18] |
|
229 long AxImpl::queryInterface(const QUuid &iid, void **iface) |
|
230 { |
|
231 *iface = 0; |
|
232 if (iid == IID_ISomeCOMInterface) |
|
233 *iface = (ISomeCOMInterface *)this; |
|
234 else |
|
235 return E_NOINTERFACE; |
|
236 |
|
237 AddRef(); |
|
238 return S_OK; |
|
239 } |
|
240 //! [18] |
|
241 |
|
242 |
|
243 //! [19] |
|
244 HRESULT AxImpl::QueryInterface(REFIID iid, void **iface) |
|
245 { |
|
246 return controllingUnknown()->QueryInterface(iid, iface); |
|
247 } |
|
248 //! [19] |
|
249 |
|
250 |
|
251 //! [20] |
|
252 class MyActiveX : public QWidget, public QAxBindable |
|
253 { |
|
254 Q_OBJECT |
|
255 |
|
256 public: |
|
257 MyActiveX(QWidget *parent); |
|
258 |
|
259 QAxAggregated *createAggregate() |
|
260 { |
|
261 return new AxImpl(); |
|
262 } |
|
263 }; |
|
264 //! [20] |