if(!actx->Create("NN", WS_CHILD|WS_VISIBLE, CRect(0,0,0,0), this, IDC_ACITVEXTEXTCTRL, NULL, FALSE, NULL))
{
TRACE0("Failed to create the FPWT Control\n");
return; // fail to create
}
actx->ShowHello();
CLSID clsid;
CLSIDFromProgID(progid, &clsid);
COleException *e = new COleException;
_DAcitveXText dac; //产生的类名是_DAcitveXText
if(dac.CreateDispatch(clsid), e)
dac.ShowHello();
else
throw e;
但是由于这时是将控件当作normal automation server来使用,必需要重载一下IsInvokeAllowed(),让它直接返回true,否则将不成功,被告之是灾难性失败,错误是编号是:8000ffff。该函数在生成ActiveX的时候重载。(不是在测试程序中)In order to use an OLE control only as an automation server, you need to override COleControl::IsInvokeAllowed()and return TRUE.If any of the control's properties and methods should not be accessed when invoked as a normal automation server, then that automation function could be bypassed and/or an error code can be returned when COleControl::m_bInitialized is FALSE.
{
// You can check to see if COleControl::m_bInitialized is FALSE
// in your automation functions to limit access.
return TRUE;
}