Click here to Skip to main content
13,199,685 members (59,179 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How to embed an activeX to Atl Composite Control?
The question is How to put one ActiveX to another?

I tried to find an answer in google but nothing was found

Let's look at an example

I'm making Atl Composite Control
My steps in visual studio 2010:
1. create Visual C++ ATL Project
2. create an Atl Composite Control e.g. "AnimWrapper" using wizard
3. insert an arbitrary ActiveX control (e.g. "Microsoft Animation Control 6.0") in resource IDD_AnimWrapper

I need to call methods of inserted Animation control in methods of my ActiveX

I will be very thankful for your help
Posted 15-Oct-12 5:33am
Updated 26-Nov-12 23:44pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

It is easy.
//ATL ActiveX wnd for the nested control, best place is as a class member
CAxWindow wndAnimationWnd; 

//best in OnCreate:
wndAnimationWnd.Create(hWndOfYourControl, //hwnd of outer control
     &rect_ForEmbededAnimation,    //client coordinates inside the outer control
     string_CLSID_OfYourAnimationControl, //must be string

Just as example, the Internet Explorer ActiveX control

CAxWindow wndBrowser; //somewhere a member inside your class

//best in OnCreate:
LPOLESTR sClsid = L"";
StringFromCLSID( CLSID_WebBrowser, &sClsid );
wndBrowser.Create(this->m_hWnd, &rcClient, sClsid, WS_CHILD | WS_VISIBLE);

After that you probably need to manipulate the control:
CComPtr<IUnknown> pUnk;
hr = AtlAxGetControl( wndBrowser, &pUnk ); //get the IUnknown of your nested control

CComQIPtr<IWebBrowser2> spBrowser2; //IDispatch or any other needed interface
hr = pUnk->QueryInterface(&spBrowser2);
CComVariant navigate_to(L"");
hr = spBrowser2->Navigate2(&navigate_to, 0, 0, 0, 0);
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Thank you for you help
Your solution really helped me work out the problem!
I needed the row
hr = AtlAxGetControl( wndBrowser, &pUnk );

So It's remained to make inner ActiveX stretch following composite control stretching.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171020.1 | Last Updated 21 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100