Win32 - ActiveX question
-
Hi! I am trying to integrate the DHTML editing control to a win32 dialog. For that I manually copy-pasted the code (CONTROL IDC_DHTML ....) from a mfc application resource to my win32 api application resource and I import the dhtmled.ocx. The program doesnt open when I click on it ( it also doesnt give an error message). Am I doing something wrong? Well... I am a beginner ...
-
Hi! I am trying to integrate the DHTML editing control to a win32 dialog. For that I manually copy-pasted the code (CONTROL IDC_DHTML ....) from a mfc application resource to my win32 api application resource and I import the dhtmled.ocx. The program doesnt open when I click on it ( it also doesnt give an error message). Am I doing something wrong? Well... I am a beginner ...
MFC does a lot of work behind the scenes to pretend that you can place an ActiveX control in your resources and have it 'just work'. See the code in DLGCORE.CPP in the MFC source, particularly
CDialog::CreateDlgIndirect
, for more details. The Win32 dialog box API knows nothing of ActiveX controls and bombs out because it cannot find a suitable window class for the ActiveX control. If you want to host ActiveX controls in a raw Win32 application, you need to implement a control site (from memory, you need to at least implement theIOleContainer
andIOleControlSite
interfaces) and then create the controls yourself. For anyone who cares, MFC preprocesses the dialog template before passing it to Windows, stripping out (but remembering) any ActiveX control data and any list box initialisations (Win32 doesn't do this either). When Windows sendsWM_INITDIALOG
to the window, MFC actually callsCDialog::HandleInitDialog
, which creates any ActiveX controls, initialises them, and performs any other control initialisations, before calling your override ofOnInitDialog
. In this way, it presents the illusion that ActiveX controls are controls like any other.