|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我写了一段代码想动态创建树控件,但是运行到 Root=pTreeCtrl.InsertItem(_T("station 1"))时出现Assertion failed错误Afxcmn.inl line:242 ASSERT(IsWindow(m_wnd)),请帮忙看看,如何解决。
谢谢了。
CComBSTR ImageFile;
CComPtr<IModelViewManager> iModelViewMgr;
CComPtr<IModelDoc2> iModelDoc;
CComPtr<IFeatMgrView> iFeatMgrView;
CComPtr<IUnknown> iUnknown;
HRESULT hr;
HTREEITEM Root;
long paneType;
CTreeView* pTreeView;
LPRECT lpRect=NULL;
VARIANT_BOOL bRet;
hr=iSwApp->get_IActiveDoc2(&iModelDoc);
hr=iModelDoc->get_ModelViewManager(&iModelViewMgr);
hr=iBmp->CreateBitmapFileFromResource(IDB_BITMAP6,&ImageFile);
hr=iModelViewMgr->CreateFeatureMgrControl2(ImageFile,_T("MSComctlLib.TreeCtrl"),_T(""),_T(""),swFeatMgrPaneTop,&iFeatMgrView);
hr=iFeatMgrView->IGetControl(&iUnknown);
hr=iUnknown->QueryInterface(IID_IOleControl,(void**)&pTreeView);
CTreeCtrl& pTreeCtrl = pTreeView->GetTreeCtrl();
Root=pTreeCtrl.InsertItem(_T("station 1"));
hr=iModelDoc->put_FeatureManagerSplitterPosition(0);
hr=iFeatMgrView->ActivateView(&paneType); |
|