Click here to Skip to main content
15,867,771 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 26-Nov-12 23:44pm
v2

It is easy.
C++
//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
     WS_CHILD | WS_VISIBLE);


Just as example, the Internet Explorer ActiveX control

C++
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:
C++
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"http://google.com");
hr = spBrowser2->Navigate2(&navigate_to, 0, 0, 0, 0);
 
Share this answer
 
v2
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900