描述:
我引入了窗体技术,
其属性设为:Style:Child,Title bar:unChecked,Visible:Checked,Control:Checked,Static edge:Checked。
在窗体上加入了MSFlexgrid控件后:
1:我为它新建一个以CDialog为基类的新类(CNewMsflexgridDialog),同时为Msflexgrid控件添加变量;
2:在CMSflexgridCtrl添加CNewMSflexgrid类的一个对象变量msfdlg。
3:在CMsflexgridCtrl::OnCreate(....)中加入msfdlg.Create(IDD_ACTIVEX_DIALOG,this);
4:在CMSflexgridCtrl::OnDraw(....)加入msfdlg.MoveWindow(rcBounds,TRUE);和msfdlg.m_msf.MoveWindow(rcBounds,TRUE);
5:将CMSflexgridApp::InitInstance()函数代码改为:
原来的如下:
BOOL bInit = COleControlModule::InitInstance();
if (bInit)
{
// TODO: Add your own module initialization code here.
}
return bInit;
改为如下:
HRESULT hr = OleInitialize(NULL);
if (hr == S_FALSE)
{
OleUninitialize();
}
// Call if using OLE Controls
AfxEnableControlContainer();
// Register all OLE server (factories) as running. This enables the
// OLE libraries to create objects from other applications.
COleObjectFactory::RegisterAll();
// TODO: Add your specialized code here
return CWinApp::InitInstance();
这时我可以在ActiveX Test control中测试运行,可是当另外新建一个项目,然后在项目的对话框上插入该新控件时,就出错。
但在 VB工程中可以正常运行。
请各位高手指教 为什么。