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?
After some trial and error and I found the answer I was after.
In the constructor of your ATL ActiveX control you to add the following line of code:
This causes the window for the control to be created (rather than just reusing the HWND of the parent window). After this the m_hWnd member of the control class can be used to access the HWND for the control’s window.