• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 826
  • Last Modified:

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.
0
mike_marquet
Asked:
mike_marquet
  • 2
  • 2
  • 2
  • +1
1 Solution
 
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
mikeblasCommented:
Why did you grade a "B"? Was there something even more that I should have done?

..B ekiM
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now