mike_marquet
asked on
CFormView in non document/view architecture
Is it possible to use a CFormView derived class in an MDI application without using the document/view architecture.
I have generated a new MDI project with Visual C++ 6.0
and unchecked the 'Document/View architecture support' in the first step of the MFC AppWizard. I wan't only to use CFormView derived classes in my MDI application. I never use the CDocument class.
I have generated a new MDI project with Visual C++ 6.0
and unchecked the 'Document/View architecture support' in the first step of the MFC AppWizard. I wan't only to use CFormView derived classes in my MDI application. I never use the CDocument class.
You can create a new class derived from CFormView, and overload the CreateWindow member, making it a public function.
Hello,
Yes, it is possible, but you must create the view yourself. I give you a generic view creation function.
// generic view creation function (not in CFrameWnd)
CWnd* CreateNewView(CCreateConte xt* pContext, CWnd *pParent, CRect& rect, int wID)
{
CWnd* pWnd = NULL;
if (pContext != NULL)
{
if (pContext->m_pNewViewClass != NULL)
{
pWnd = (CWnd*)pContext->m_pNewVie wClass->Cr eateObject ();
if (pWnd == NULL)
{
TRACE1("Error: Dynamic create of view %Fs failed\n",
pContext->m_pNewViewClass- >m_lpszCla ssName);
return NULL;
}
ASSERT(pWnd->IsKindOf(RUNT IME_CLASS( CWnd)));
if (!pWnd->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
rect, pParent, wID, pContext))
{
TRACE0("Error: couldn't create view \n");
return NULL;
}
// send initial notification message
pWnd->SendMessage(WM_INITI ALUPDATE);
}
}
return pWnd;
}
You must have DECLARE_DYNCREATE in your code.
If necessary, I can build a sample.
regards, jean-claude.
Yes, it is possible, but you must create the view yourself. I give you a generic view creation function.
// generic view creation function (not in CFrameWnd)
CWnd* CreateNewView(CCreateConte
{
CWnd* pWnd = NULL;
if (pContext != NULL)
{
if (pContext->m_pNewViewClass
{
pWnd = (CWnd*)pContext->m_pNewVie
if (pWnd == NULL)
{
TRACE1("Error: Dynamic create of view %Fs failed\n",
pContext->m_pNewViewClass-
return NULL;
}
ASSERT(pWnd->IsKindOf(RUNT
if (!pWnd->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
rect, pParent, wID, pContext))
{
TRACE0("Error: couldn't create view \n");
return NULL;
}
// send initial notification message
pWnd->SendMessage(WM_INITI
}
}
return pWnd;
}
You must have DECLARE_DYNCREATE in your code.
If necessary, I can build a sample.
regards, jean-claude.
ASKER
To jclanz :
How can I use this function to create my CFormView !
Can you build me a sample and send me this sample to
mike.marquet@altavista.net
Thanks.
I will evaluate you later.
How can I use this function to create my CFormView !
Can you build me a sample and send me this sample to
mike.marquet@altavista.net
Thanks.
I will evaluate you later.
ASKER
To Gandalf32 :
Can you give me an example ?
Can you give me an example ?
Hello,
You are right, this function is normaly to build a view without frame (in a dialog). In MDI you have a frame so you can use CreateView() to do this.
I send the sample to your e-mail.
regards, jean-claude.
You are right, this function is normaly to build a view without frame (in a dialog). In MDI you have a frame so you can use CreateView() to do this.
I send the sample to your e-mail.
regards, jean-claude.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Why did you grade a "B"? Was there something even more that I should have done?
..B ekiM
..B ekiM