Link to home
Start Free TrialLog in
Avatar of brisco
brisco

asked on

ActiveX Control as a container

Hi,
Is it possible to have an activeX control also serve as a container to load other activeX controls?  I have manually inserted the correct include in stdafx.h "#include <afxdisp.h>"  and called  "AfxEnableControlContainer();" into the control's InitInstance.

The following is a code snippet from a dialog class that that creates the control.  If I embed this dialog
class in an .exe, the createcontrol works.  If I embed this
dialog class in an activex control, the createcontrol call fails (without returning a meaningful error code).

RECT MySize = {0,0,400,400};
m_nID = 10;

CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CMsacal70);
m_pCsCRCLD = (CMsacal70*)pRuntimeClass->CreateObject();

BOOL bResult = m_pCsCRCLD->CreateControl("MSACAL.MSACALCtrl.7",_T(""),WS_VISIBLE,MySize,this,m_nID);

if (bResult == FALSE)
{
      delete m_pCsCRCLD;
      AfxMessageBox("Control creation failed");
}


Is there anything else that needs to be done when an activex
control is being created inside of another activex control?
Can this be done?

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brisco
brisco

ASKER

This solution does work, but I have found that having the dialog created from a CWinThread prevents the control from sucessfully loading.  Not sure why.