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.
mike_marquetAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gandalf32Commented:
You can create a new class derived from CFormView, and overload the CreateWindow member, making it a public function.
0
jclanzCommented:
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(CCreateContext* pContext, CWnd *pParent, CRect& rect, int wID)
{
    CWnd* pWnd = NULL;

    if (pContext != NULL)
    {
            if (pContext->m_pNewViewClass != NULL)
            {
                  pWnd = (CWnd*)pContext->m_pNewViewClass->CreateObject();
                  if (pWnd == NULL)
                  {
                        TRACE1("Error: Dynamic create of view %Fs failed\n",
                              pContext->m_pNewViewClass->m_lpszClassName);
                        return NULL;
                  }
                  ASSERT(pWnd->IsKindOf(RUNTIME_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_INITIALUPDATE);
            }
    }
    return pWnd;
}

You must have DECLARE_DYNCREATE in your code.

If necessary, I can build a sample.

regards, jean-claude.

0
mike_marquetAuthor Commented:
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.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

mike_marquetAuthor Commented:
To Gandalf32 :

Can you give me an example ?
0
jclanzCommented:
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.
0
mikeblasCommented:
Asking for a complete sample and offering only 25 points is morally wrong. But I want to see what it's like to be even more charitable than normal.

It's really pretty simple; just create a modeless dialog box as a child of the child frame instead of a CWnd-derived window.

You can find a sample that does what you're asking about in the NoForm.ZIP file at http://www.nwlink.com/~mikeblas/samples/ . (Note: my website will soon be moving to http://www.mooseboy.com/ )

..B ekiM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mikeblasCommented:
Why did you grade a "B"? Was there something even more that I should have done?

..B ekiM
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.