CMDIChildWnd size problem in DOC/View OCX
-
I want to migrate a MFC doc/view application to an activex control. I create the CMainFrame(inherited from CMDIFrameWnd) object when the activeX control is Created. but when i open a document, access violation occured in user.dll and no source code. i found the error is from CMDIChildFrame::OnSize. the following is my code : BOOL CMultiDocOCXCtrl::CreateMDIFrame() { if(m_pFrameWnd != NULL) return FALSE; CRect rc; GetClientRect(&rc); CMultiDocTemplate* pDocTemplate = new CMultiDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CMyDocument), RUNTIME_CLASS(CChildFrame), RUNTIME_CLASS(CMyView)); AfxGetApp()->AddDocTemplate(pDocTemplate); // CString sClassName = AfxRegisterWndClass(CS_DBLCLKS); CMainFrame * pFrame = new CMainFrame; if(!pFrame->Create(sClassName, NULL, WS_CHILD|WS_VISIBLE, rc, this, MAKEINTRESOURCE(IDR_MAINFRAME), 0, NULL)) { delete pFrame; return FALSE; } pFrame->ShowWindow(SW_SHOW); pFrame->RecalcLayout(); // m_pFrameWnd = pFrame; // AfxGetApp()->m_pMainWnd = m_pFrameWnd; theApp.OnNewFile(); // return TRUE; } Is anybody know how this problem occur? c++ : my dream