Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ ATL ActiveX
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
Jecka1.6K
Edited 26-Nov-12 23:44pm
v2
Rate this: bad
good
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
     WS_CHILD | WS_VISIBLE);
 
 
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"http://google.com");
hr = spBrowser2->Navigate2(&navigate_to, 0, 0, 0, 0);
 
  Permalink  
v2
Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 405
1 Maciej Los 285
2 Peter Leow 128
3 Kornfeld Eliyahu Peter 119
4 DamithSL 119


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