Click to See Complete Forum and Search --> : Howto dynamically add an ActiveX control to an MFC window?


Douglas Peterson
July 19th, 1999, 11:47 AM
I can't seem to figure out what I need to do to add an ActiveX control to an MFC window (like CDialog) at runtime.

It must be possible since you can add one to a dialog template and you only have to add one line of code to InitInstance (AfxEnableControlContainer();). So somebody, MFC or Window's, knows how to do it.

chiuyan
July 19th, 1999, 12:02 PM
You need to add the activeX to your project via the Project / Add To Project / Components and Controls menu option. This will create a dummy class to wrap the activeX control. Then in your window's OnCreate (or wherever you want), you just create your control via MyDummyClass.Create () (all controls are derived from CWnd).

HTH
--michael

Douglas Peterson
July 19th, 1999, 04:13 PM
My app will have no prior knowledge of the control, it will know only it's GUID.

I discovered the answer rather accidentally:

I was browsing through much and mire of MFC (the source code), and came across the CHtmlView class. It gave me the details I needed. CWnd::CreateControl.