RainMan
2007-11-27 20:52:01 UTC
I assume you have MDI application and you are trying to create another child
frame with view that is wired to the same document. Try this:
CRuntimeClass *pClass = RUNTIME_CLASS(CChildFrame);
ASSERT(pViewClass);
CChildFrame *pNewFrame = (CChildFrame*)pClass->CreateObject();
You can pass CMDIChildWnd for a class if you do not want to have any control
over the frame behavior.
If you still have problem with ASSERT please post exact code that causes
assertion.
--
RainMan
frame with view that is wired to the same document. Try this:
CRuntimeClass *pClass = RUNTIME_CLASS(CChildFrame);
ASSERT(pViewClass);
CChildFrame *pNewFrame = (CChildFrame*)pClass->CreateObject();
You can pass CMDIChildWnd for a class if you do not want to have any control
over the frame behavior.
If you still have problem with ASSERT please post exact code that causes
assertion.
--
RainMan
VOID CSampleDoc::CreateNewView(CView* pView,CRuntimeClass* pRuntimeClass)
{
CFrameWnd* pMainWnd = (CFrameWnd*) AfxGetMainWnd();
CFrameWnd* pNewFrame = (CFrameWnd*) pMainWnd->CreateObject();
CCreateContext context;
context.m_pCurrentDoc = this;
// context.m_pLastView = pView;
// context.m_pCurrentFrame = pMainWnd;
context.m_pNewViewClass = RUNTIME_CLASS(CCustomView);
// context.m_pNewDocTemplate = GetDocTemplate();
pNewFrame->LoadFrame(IDR_CustomTYPE,WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, &context);
pNewFrame->SetTitle(L"Test");
pNewFrame->InitialUpdateFrame(NULL, TRUE);
}
This code is called from the active view (this is a samaple a I've made for tests, not the real app) and it creates another type of view OK, but it is always an overlapped window. If I change window type to WS_CHILD I always get an assert - it seems I can't figure what windows should be used as a parent one.
Any help/hints/ideas welcome
Thank you for your time
--
Regards,
Waleri
{
CFrameWnd* pMainWnd = (CFrameWnd*) AfxGetMainWnd();
CFrameWnd* pNewFrame = (CFrameWnd*) pMainWnd->CreateObject();
CCreateContext context;
context.m_pCurrentDoc = this;
// context.m_pLastView = pView;
// context.m_pCurrentFrame = pMainWnd;
context.m_pNewViewClass = RUNTIME_CLASS(CCustomView);
// context.m_pNewDocTemplate = GetDocTemplate();
pNewFrame->LoadFrame(IDR_CustomTYPE,WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, &context);
pNewFrame->SetTitle(L"Test");
pNewFrame->InitialUpdateFrame(NULL, TRUE);
}
This code is called from the active view (this is a samaple a I've made for tests, not the real app) and it creates another type of view OK, but it is always an overlapped window. If I change window type to WS_CHILD I always get an assert - it seems I can't figure what windows should be used as a parent one.
Any help/hints/ideas welcome
Thank you for your time
--
Regards,
Waleri