1*520fa265SAndrew Rist /**************************************************************
2*520fa265SAndrew Rist  *
3*520fa265SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*520fa265SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*520fa265SAndrew Rist  * distributed with this work for additional information
6*520fa265SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*520fa265SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*520fa265SAndrew Rist  * "License"); you may not use this file except in compliance
9*520fa265SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*520fa265SAndrew Rist  *
11*520fa265SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*520fa265SAndrew Rist  *
13*520fa265SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*520fa265SAndrew Rist  * software distributed under the License is distributed on an
15*520fa265SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*520fa265SAndrew Rist  * KIND, either express or implied.  See the License for the
17*520fa265SAndrew Rist  * specific language governing permissions and limitations
18*520fa265SAndrew Rist  * under the License.
19*520fa265SAndrew Rist  *
20*520fa265SAndrew Rist  *************************************************************/
21*520fa265SAndrew Rist 
22cdf0e10cSrcweir // MfcControlCtl.cpp : Implementation of the CMfcControlCtrl ActiveX Control class.
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "stdafx.h"
25cdf0e10cSrcweir #include "MfcControl.h"
26cdf0e10cSrcweir #include "MfcControlCtl.h"
27cdf0e10cSrcweir #include "MfcControlPpg.h"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #ifdef _DEBUG
31cdf0e10cSrcweir #define new DEBUG_NEW
32cdf0e10cSrcweir #undef THIS_FILE
33cdf0e10cSrcweir static char THIS_FILE[] = __FILE__;
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 
37cdf0e10cSrcweir IMPLEMENT_DYNCREATE(CMfcControlCtrl, COleControl)
38cdf0e10cSrcweir 
39cdf0e10cSrcweir 
40cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
41cdf0e10cSrcweir // Message map
42cdf0e10cSrcweir 
43cdf0e10cSrcweir BEGIN_MESSAGE_MAP(CMfcControlCtrl, COleControl)
44cdf0e10cSrcweir 	//{{AFX_MSG_MAP(CMfcControlCtrl)
45cdf0e10cSrcweir 	// NOTE - ClassWizard will add and remove message map entries
46cdf0e10cSrcweir 	//    DO NOT EDIT what you see in these blocks of generated code !
47cdf0e10cSrcweir 	//}}AFX_MSG_MAP
48cdf0e10cSrcweir 	ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
49cdf0e10cSrcweir END_MESSAGE_MAP()
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 
52cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
53cdf0e10cSrcweir // Dispatch map
54cdf0e10cSrcweir 
55cdf0e10cSrcweir BEGIN_DISPATCH_MAP(CMfcControlCtrl, COleControl)
56cdf0e10cSrcweir 	//{{AFX_DISPATCH_MAP(CMfcControlCtrl)
57cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "inShort", inShort, VT_I2, VTS_I2)
58cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "inLong", inLong, VT_I4, VTS_I4)
59cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "inString", inString, VT_BSTR, VTS_PBSTR)
60cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "inFloat", inFloat, VT_R4, VTS_R4)
61cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "inDouble", inDouble, VT_R8, VTS_R8)
62cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "inVariant", inVariant, VT_VARIANT, VTS_VARIANT)
63cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "inObject", inObject, VT_DISPATCH, VTS_DISPATCH)
64cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "outShort", outShort, VT_EMPTY, VTS_PI2)
65cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "outLong", outLong, VT_EMPTY, VTS_PI4)
66cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "outString", outString, VT_EMPTY, VTS_PBSTR)
67cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "outFloat", outFloat, VT_EMPTY, VTS_PR4)
68cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "outDouble", outDouble, VT_EMPTY, VTS_PR8)
69cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "outVariant", outVariant, VT_EMPTY, VTS_PVARIANT)
70cdf0e10cSrcweir 	DISP_FUNCTION(CMfcControlCtrl, "outObject", outObject, VT_EMPTY, VTS_PDISPATCH)
71cdf0e10cSrcweir 	//}}AFX_DISPATCH_MAP
72cdf0e10cSrcweir END_DISPATCH_MAP()
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 
75cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
76cdf0e10cSrcweir // Event map
77cdf0e10cSrcweir 
78cdf0e10cSrcweir BEGIN_EVENT_MAP(CMfcControlCtrl, COleControl)
79cdf0e10cSrcweir 	//{{AFX_EVENT_MAP(CMfcControlCtrl)
80cdf0e10cSrcweir 	// NOTE - ClassWizard will add and remove event map entries
81cdf0e10cSrcweir 	//    DO NOT EDIT what you see in these blocks of generated code !
82cdf0e10cSrcweir 	//}}AFX_EVENT_MAP
83cdf0e10cSrcweir END_EVENT_MAP()
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 
86cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
87cdf0e10cSrcweir // Property pages
88cdf0e10cSrcweir 
89cdf0e10cSrcweir // TODO: Add more property pages as needed.  Remember to increase the count!
90cdf0e10cSrcweir BEGIN_PROPPAGEIDS(CMfcControlCtrl, 1)
91cdf0e10cSrcweir 	PROPPAGEID(CMfcControlPropPage::guid)
92cdf0e10cSrcweir END_PROPPAGEIDS(CMfcControlCtrl)
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 
95cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
96cdf0e10cSrcweir // Initialize class factory and guid
97cdf0e10cSrcweir 
98cdf0e10cSrcweir IMPLEMENT_OLECREATE_EX(CMfcControlCtrl, "MFCCONTROL.MfcControlCtrl.1",
99cdf0e10cSrcweir 	0xac221fb6, 0xa0d8, 0x11d4, 0x83, 0x3b, 0, 0x50, 0x4, 0x52, 0x6a, 0xb4)
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 
102cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
103cdf0e10cSrcweir // Type library ID and version
104cdf0e10cSrcweir 
105cdf0e10cSrcweir IMPLEMENT_OLETYPELIB(CMfcControlCtrl, _tlid, _wVerMajor, _wVerMinor)
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 
108cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
109cdf0e10cSrcweir // Interface IDs
110cdf0e10cSrcweir 
111cdf0e10cSrcweir const IID BASED_CODE IID_DMfcControl =
112cdf0e10cSrcweir 		{ 0xac221fb4, 0xa0d8, 0x11d4, { 0x83, 0x3b, 0, 0x50, 0x4, 0x52, 0x6a, 0xb4 } };
113cdf0e10cSrcweir const IID BASED_CODE IID_DMfcControlEvents =
114cdf0e10cSrcweir 		{ 0xac221fb5, 0xa0d8, 0x11d4, { 0x83, 0x3b, 0, 0x50, 0x4, 0x52, 0x6a, 0xb4 } };
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 
117cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
118cdf0e10cSrcweir // Control type information
119cdf0e10cSrcweir 
120cdf0e10cSrcweir static const DWORD BASED_CODE _dwMfcControlOleMisc =
121cdf0e10cSrcweir 	OLEMISC_ACTIVATEWHENVISIBLE |
122cdf0e10cSrcweir 	OLEMISC_SETCLIENTSITEFIRST |
123cdf0e10cSrcweir 	OLEMISC_INSIDEOUT |
124cdf0e10cSrcweir 	OLEMISC_CANTLINKINSIDE |
125cdf0e10cSrcweir 	OLEMISC_RECOMPOSEONRESIZE;
126cdf0e10cSrcweir 
IMPLEMENT_OLECTLTYPE(CMfcControlCtrl,IDS_MFCCONTROL,_dwMfcControlOleMisc)127cdf0e10cSrcweir IMPLEMENT_OLECTLTYPE(CMfcControlCtrl, IDS_MFCCONTROL, _dwMfcControlOleMisc)
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 
130cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
131cdf0e10cSrcweir // CMfcControlCtrl::CMfcControlCtrlFactory::UpdateRegistry -
132cdf0e10cSrcweir // Adds or removes system registry entries for CMfcControlCtrl
133cdf0e10cSrcweir 
134cdf0e10cSrcweir BOOL CMfcControlCtrl::CMfcControlCtrlFactory::UpdateRegistry(BOOL bRegister)
135cdf0e10cSrcweir {
136cdf0e10cSrcweir 	// TODO: Verify that your control follows apartment-model threading rules.
137cdf0e10cSrcweir 	// Refer to MFC TechNote 64 for more information.
138cdf0e10cSrcweir 	// If your control does not conform to the apartment-model rules, then
139cdf0e10cSrcweir 	// you must modify the code below, changing the 6th parameter from
140cdf0e10cSrcweir 	// afxRegApartmentThreading to 0.
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	if (bRegister)
143cdf0e10cSrcweir 		return AfxOleRegisterControlClass(
144cdf0e10cSrcweir 			AfxGetInstanceHandle(),
145cdf0e10cSrcweir 			m_clsid,
146cdf0e10cSrcweir 			m_lpszProgID,
147cdf0e10cSrcweir 			IDS_MFCCONTROL,
148cdf0e10cSrcweir 			IDB_MFCCONTROL,
149cdf0e10cSrcweir 			afxRegApartmentThreading,
150cdf0e10cSrcweir 			_dwMfcControlOleMisc,
151cdf0e10cSrcweir 			_tlid,
152cdf0e10cSrcweir 			_wVerMajor,
153cdf0e10cSrcweir 			_wVerMinor);
154cdf0e10cSrcweir 	else
155cdf0e10cSrcweir 		return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
156cdf0e10cSrcweir }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 
159cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
160cdf0e10cSrcweir // CMfcControlCtrl::CMfcControlCtrl - Constructor
161cdf0e10cSrcweir 
CMfcControlCtrl()162cdf0e10cSrcweir CMfcControlCtrl::CMfcControlCtrl()
163cdf0e10cSrcweir {
164cdf0e10cSrcweir 	InitializeIIDs(&IID_DMfcControl, &IID_DMfcControlEvents);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	// TODO: Initialize your control's instance data here.
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 
170cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
171cdf0e10cSrcweir // CMfcControlCtrl::~CMfcControlCtrl - Destructor
172cdf0e10cSrcweir 
~CMfcControlCtrl()173cdf0e10cSrcweir CMfcControlCtrl::~CMfcControlCtrl()
174cdf0e10cSrcweir {
175cdf0e10cSrcweir 	// TODO: Cleanup your control's instance data here.
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 
179cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
180cdf0e10cSrcweir // CMfcControlCtrl::OnDraw - Drawing function
181cdf0e10cSrcweir 
OnDraw(CDC * pdc,const CRect & rcBounds,const CRect & rcInvalid)182cdf0e10cSrcweir void CMfcControlCtrl::OnDraw(
183cdf0e10cSrcweir 			CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
184cdf0e10cSrcweir {
185cdf0e10cSrcweir 	// TODO: Replace the following code with your own drawing code.
186cdf0e10cSrcweir 	pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
187cdf0e10cSrcweir 	pdc->Ellipse(rcBounds);
188cdf0e10cSrcweir }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 
191cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
192cdf0e10cSrcweir // CMfcControlCtrl::DoPropExchange - Persistence support
193cdf0e10cSrcweir 
DoPropExchange(CPropExchange * pPX)194cdf0e10cSrcweir void CMfcControlCtrl::DoPropExchange(CPropExchange* pPX)
195cdf0e10cSrcweir {
196cdf0e10cSrcweir 	ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
197cdf0e10cSrcweir 	COleControl::DoPropExchange(pPX);
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 	// TODO: Call PX_ functions for each persistent custom property.
200cdf0e10cSrcweir 
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 
204cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
205cdf0e10cSrcweir // CMfcControlCtrl::OnResetState - Reset control to default state
206cdf0e10cSrcweir 
OnResetState()207cdf0e10cSrcweir void CMfcControlCtrl::OnResetState()
208cdf0e10cSrcweir {
209cdf0e10cSrcweir 	COleControl::OnResetState();  // Resets defaults found in DoPropExchange
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 	// TODO: Reset any other control state here.
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 
215cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
216cdf0e10cSrcweir // CMfcControlCtrl message handlers
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 
inShort(short val)219cdf0e10cSrcweir short CMfcControlCtrl::inShort(short val)
220cdf0e10cSrcweir {
221cdf0e10cSrcweir 	char buf[256];
222cdf0e10cSrcweir 	sprintf( buf, "inByte: value= %d", val);
223cdf0e10cSrcweir 	::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
224cdf0e10cSrcweir 	return val+1;
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
inLong(long val)227cdf0e10cSrcweir long CMfcControlCtrl::inLong(long val)
228cdf0e10cSrcweir {
229cdf0e10cSrcweir 	char buf[256];
230cdf0e10cSrcweir 	sprintf( buf, "inLong: value= %d", val);
231cdf0e10cSrcweir 	::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
232cdf0e10cSrcweir 	return val+1;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir 
inString(BSTR * val)235cdf0e10cSrcweir BSTR CMfcControlCtrl::inString(BSTR* val)
236cdf0e10cSrcweir {
237cdf0e10cSrcweir 	CString strResult;
238cdf0e10cSrcweir 	strResult= *val;
239cdf0e10cSrcweir 	char buf[256];
240cdf0e10cSrcweir 	sprintf( buf, "inString: value= %S", *val);
241cdf0e10cSrcweir 	::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
242cdf0e10cSrcweir 	strResult += L" an appended string";
243cdf0e10cSrcweir 	return strResult.AllocSysString();
244cdf0e10cSrcweir }
245cdf0e10cSrcweir 
inFloat(float val)246cdf0e10cSrcweir float CMfcControlCtrl::inFloat(float val)
247cdf0e10cSrcweir {
248cdf0e10cSrcweir 	char buf[256];
249cdf0e10cSrcweir 	sprintf( buf, "inFloat: value= %f", val);
250cdf0e10cSrcweir 	::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
251cdf0e10cSrcweir 	return val+1;
252cdf0e10cSrcweir }
253cdf0e10cSrcweir 
inDouble(double val)254cdf0e10cSrcweir double CMfcControlCtrl::inDouble(double val)
255cdf0e10cSrcweir {
256cdf0e10cSrcweir 	char buf[256];
257cdf0e10cSrcweir 	sprintf( buf, "inDouble: value= %g", val);
258cdf0e10cSrcweir 	::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
259cdf0e10cSrcweir 	return val+1;
260cdf0e10cSrcweir }
261cdf0e10cSrcweir 
inVariant(const VARIANT FAR & val)262cdf0e10cSrcweir VARIANT CMfcControlCtrl::inVariant(const VARIANT FAR& val)
263cdf0e10cSrcweir {
264cdf0e10cSrcweir 	VARIANT vaResult;
265cdf0e10cSrcweir 	VariantInit(&vaResult);
266cdf0e10cSrcweir 	VariantCopyInd( &vaResult, const_cast<VARIANT*>(&val));
267cdf0e10cSrcweir 	if( vaResult.vt == VT_BSTR)
268cdf0e10cSrcweir 	{
269cdf0e10cSrcweir 		char buf[256];
270cdf0e10cSrcweir 		sprintf( buf, "inVariant: value= %S", vaResult.bstrVal);
271cdf0e10cSrcweir 		::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 	}
274cdf0e10cSrcweir 	return _variant_t( L" a string from CMfcControlCtrl::inVariant");
275cdf0e10cSrcweir }
276cdf0e10cSrcweir 
inObject(LPDISPATCH val)277cdf0e10cSrcweir LPDISPATCH CMfcControlCtrl::inObject(LPDISPATCH val)
278cdf0e10cSrcweir {
279cdf0e10cSrcweir 	char buf[256];
280cdf0e10cSrcweir 	_bstr_t bstr;
281cdf0e10cSrcweir 	HRESULT hr= S_OK;
282cdf0e10cSrcweir 	COleVariant var;
283cdf0e10cSrcweir 	DISPID id;
284cdf0e10cSrcweir 	OLECHAR* name=L"prpString";
285cdf0e10cSrcweir 	if( SUCCEEDED(hr= val->GetIDsOfNames( IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &id)))
286cdf0e10cSrcweir 	{
287cdf0e10cSrcweir 		DISPPARAMS params={0,0,0,0};
288cdf0e10cSrcweir 		hr= val->Invoke( id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &params, &var,0,0);
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 	}
291cdf0e10cSrcweir 
292cdf0e10cSrcweir 	if( var.vt== VT_BSTR)
293cdf0e10cSrcweir 		bstr= var.bstrVal;
294cdf0e10cSrcweir 	sprintf( buf, "inObject: value= %S", (wchar_t*)bstr);
295cdf0e10cSrcweir 	::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 	return NULL;
298cdf0e10cSrcweir }
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 
outShort(short * val)301cdf0e10cSrcweir void CMfcControlCtrl::outShort(short* val)
302cdf0e10cSrcweir {
303cdf0e10cSrcweir 	*val= 123;
304cdf0e10cSrcweir }
305cdf0e10cSrcweir 
outLong(long * val)306cdf0e10cSrcweir void CMfcControlCtrl::outLong(long* val)
307cdf0e10cSrcweir {
308cdf0e10cSrcweir 	*val= 1234;
309cdf0e10cSrcweir }
310cdf0e10cSrcweir 
outString(BSTR FAR * val)311cdf0e10cSrcweir void CMfcControlCtrl::outString(BSTR FAR* val)
312cdf0e10cSrcweir {
313cdf0e10cSrcweir 	*val= SysAllocString(L"A string from CMfcControlCtrl::outString ");
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
outFloat(float * val)316cdf0e10cSrcweir void CMfcControlCtrl::outFloat(float* val)
317cdf0e10cSrcweir {
318cdf0e10cSrcweir 	*val= 3.14f;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
outDouble(double * val)321cdf0e10cSrcweir void CMfcControlCtrl::outDouble(double* val)
322cdf0e10cSrcweir {
323cdf0e10cSrcweir 	*val= 3.145;
324cdf0e10cSrcweir }
325cdf0e10cSrcweir 
outVariant(VARIANT FAR * val)326cdf0e10cSrcweir void CMfcControlCtrl::outVariant(VARIANT FAR* val)
327cdf0e10cSrcweir {
328cdf0e10cSrcweir 	VariantInit( val);
329cdf0e10cSrcweir 	val->vt= VT_BSTR;
330cdf0e10cSrcweir 	val->bstrVal= SysAllocString( L"a string in a VARIANT");
331cdf0e10cSrcweir }
332cdf0e10cSrcweir 
outObject(LPDISPATCH FAR * val)333cdf0e10cSrcweir void CMfcControlCtrl::outObject(LPDISPATCH FAR* val)
334cdf0e10cSrcweir {
335cdf0e10cSrcweir 	//{BFE10EBE-8584-11D4-005004526AB4}
336cdf0e10cSrcweir 	HRESULT hr= S_OK;
337cdf0e10cSrcweir 	CLSID clsTestControl;
338cdf0e10cSrcweir 	hr= CLSIDFromProgID( L"AxTestComponents.Basic", &clsTestControl);
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 	IDispatch* pDisp= NULL;
341cdf0e10cSrcweir 	hr=	CoCreateInstance( clsTestControl, NULL, CLSCTX_ALL, __uuidof(IDispatch), (void**)&pDisp);
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 	if( SUCCEEDED( hr) && val)
344cdf0e10cSrcweir 	{
345cdf0e10cSrcweir 		COleVariant var;
346cdf0e10cSrcweir 		DISPID id;
347cdf0e10cSrcweir 		OLECHAR* name=L"prpString";
348cdf0e10cSrcweir 		if( SUCCEEDED(hr= pDisp->GetIDsOfNames( IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &id)))
349cdf0e10cSrcweir 		{
350cdf0e10cSrcweir 			COleVariant vaParam1(_T("this is property prpString of AxTestComponents.Basic"));
351cdf0e10cSrcweir 			DISPID dispidPut= DISPID_PROPERTYPUT;
352cdf0e10cSrcweir 			DISPPARAMS params;
353cdf0e10cSrcweir 			params.cArgs= 1;
354cdf0e10cSrcweir 			params.cNamedArgs= 1;
355cdf0e10cSrcweir 			params.rgdispidNamedArgs= &dispidPut;
356cdf0e10cSrcweir 			params.rgvarg= &vaParam1;
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 			hr= pDisp->Invoke( id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &params, &var,0,0);
359cdf0e10cSrcweir 			*val= pDisp;
360cdf0e10cSrcweir 		}
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 	}
363cdf0e10cSrcweir 
364cdf0e10cSrcweir }
365cdf0e10cSrcweir // VT_I1
366