Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2006

Tip: Looking for answers? Try searching our database.

how make new SDI Window with different view in MFC?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Neo - 29 Jun 2006 14:24 GMT
I am going to make SDI base application in MFC, which has a button for "New
Window", will show new window with different view.

How I can solve this problem? Main window view class inherited with
CListView, and New Window view class inherited with CFormView.

------------: Following windows are registered :------------

CSingleDocTemplate * pDocTemplate;

    pDocTemplate = new CSingleDocTemplate(

    IDR_MAINFRAME,

    RUNTIME_CLASS(COtengoDoc),

    RUNTIME_CLASS(CMainFrame),

    RUNTIME_CLASS(COtengoView)); //Base Class of COtengoView is CListView

    if (!pDocTemplate)

         return FALSE;

    AddDocTemplate(pDocTemplate); //Registered Main Window

pDocTemplate = new CSingleDocTemplate(

    IDR_MAINFRAME1,

    RUNTIME_CLASS(CNewMsgDoc),

    RUNTIME_CLASS(CNewMsgFrm),

    RUNTIME_CLASS(CNewMsgView)); //Base Class of CNewMsgView is CFormView

    if (!pDocTemplate)

         return FALSE;

    AddDocTemplate(pDocTemplate);

------------: For New Window code :------------

CSingleDocTemplate * m_pDocTemplate;

m_pDocTemplate = new CSingleDocTemplate(

IDR_MAINFRAME1,

RUNTIME_CLASS(CNewMsgDoc),

RUNTIME_CLASS(CNewMsgFrm),

RUNTIME_CLASS(CNewMsgView));

CDocument * pDoc = NULL;

CFrameWnd * pFrame = NULL;

pDoc = m_pDocTemplate->CreateNewDocument( );

if( pDoc != NULL )

{

    pFrame = m_pDocTemplate->CreateNewFrame( pDoc, pFrame ); // <--
Exception comes

    if( pFrame != NULL )

    {

         m_pDocTemplate->SetDefaultTitle( pDoc );

         if( ! pDoc->OnNewDocument( ) )

         {

             pFrame->DestroyWindow( );

             pFrame = NULL;

         }

         else

         {

             m_pDocTemplate->InitialUpdateFrame( pFrame, pDoc, TRUE );

         }

    }

}

if( pFrame == NULL || pDoc == NULL )

{

    delete pDoc;

    AfxMessageBox( AFX_IDP_FAILED_TO_CREATE_DOC );

}

in this code, when "pFrame = m_pDocTemplate->CreateNewFrame( pDoc,
pFrame );" give exception comes on this code

File : viewform.cpp

#ifdef _DEBUG

    // dialog template must exist and be invisible with WS_CHILD set

    if (!_AfxCheckDialogTemplate(m_lpszTemplateName, TRUE))

    {

         ASSERT(FALSE);          // invalid dialog template name

         PostNcDestroy();        // cleanup if Create fails too soon

         return FALSE;

    }

#endif //_DEBUG

tell me, how solve this problem?

regards,

Mohammad Omer Nasir.
William DePalo [MVP VC++] - 29 Jun 2006 15:25 GMT
>I am going to make SDI base application in MFC, which has
> a button for "New Window", will show new window with
> different view.

If no one responds here try posting again in one of the MFC groups, perhaps
here:

   microsoft.public.vc.mfc.docview

Regards,
Will
www.fruitfruit.com - 30 Jun 2006 04:18 GMT
> I am going to make SDI base application in MFC, which has a button for "New
> Window", will show new window with different view.
[quoted text clipped - 131 lines]
>
> Mohammad Omer Nasir.

In my understanding, AddDocTemplate(pDocTemplate); is used to add
document template, not for registering View class.
here is a sample for mulitple view in SDI
support.microsoft.com/support/kb/articles/q141/3/33.asp
VSWAP Demos Multiple-View Switching in SDI
Neo - 03 Jul 2006 08:19 GMT
thanks alot,

regards,
Mohammad Omer Nasir.

> > I am going to make SDI base application in MFC, which has a button for "New
> > Window", will show new window with different view.
[quoted text clipped - 137 lines]
> support.microsoft.com/support/kb/articles/q141/3/33.asp
> VSWAP Demos Multiple-View Switching in SDI

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.