3,245
社区成员
发帖
与我相关
我的任务
分享
int CFormAVCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
m_helloFormView = new CHelloFormView();
m_helloFormView->Create(NULL,NULL,AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL);
return 0;
}
CFormAVCtrl::~CFormAVCtrl()
{
//if( NULL != m_helloFormView) delete m_helloFormView; //一般认为声明了指针最后是要释放内存的,但是这里这么做不行
}
void CView::OnDestroy()
{
CFrameWnd* pFrame = GetParentFrame(); //这句在ActiveX中使用返回总是NULL
if (pFrame != NULL && pFrame->GetActiveView() == this)
pFrame->SetActiveView(NULL); // deactivate during death
CWnd::OnDestroy();
}