C++ – How to get the HWND for an ActiveX control after the control has been initialised/activated

activexatlc

I am creating an ATL 8.0 based ActiveX control in C++ using Visual Studio 2008. I need to create a sub-window and attach it to the ActiveX control.

How do I get access to the HWND that is owned by the ActiveX control?

Which ATL function can I override in order to use the HWND after the control's window has been created?

Best Answer

ActiveX would allow you to define your own methods on your own interface (to address Brians assumption), but that likely won't help here. The ActiveX control might very well be created by another component. ATL too is irrelevant - it's a C++ template library that wraps COM interfaces.

The function you need here is IOleWindow::GetWindow. I'm not sure what you mean by "override an ATL function to use the HWMD". Once you have retrieved the HWND, you can pass it to any function that uses an HWND. For instance, as the parent in SetParent(child, parent)

Related Topic