Solved

mdi application

Posted on 2010-11-19
10
1,060 Views
Last Modified: 2012-05-10
#include<afxwin.h>
#include<afxext.h>
#include "resource.h"

class WinApp : public CWinApp
{
      BOOL InitInstance();
      DECLARE_MESSAGE_MAP()
};

class CMainFrame : public CMDIFrameWnd
{
      DECLARE_DYNCREATE(CMainFrame)
};

IMPLEMENT_DYNCREATE(CMainFrame,CMDIFrameWnd)

class CDoc1:public CDocument
{
      void serialize(CArchive &a);
      DECLARE_DYCREATE(CDoc1);
};

IMPLEMENT_DYNCREATE(CDoc1,CDocument)

void CDoc1::serialize(CArchive &a)
{
      ((CEditView*)m_viewList.GetHead())->SerializeRaw(ar);
}

BEGIN_MESSAGE_MAP(CDoc1,CDocument)
ON_COMMAND(ID_FILE_NEW,CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN,CWinApp::OnFileOpen)
END_MESSAGE_MAP()

BOOL WinApp::InitInstance()
{
      AddDocTemplate(new CMultiDocTemplate(IDR_MENU1,RUNTIME_CLASS(CDoc1),RUNTIME_CLASS(CMainFrame),RUNTIME_CLASS(CEditView)));
      m_pMainWnd = new CMainFrame;
      ((CFrameWnd*) m_pMainWnd)->LoadFrame(IDR_MENU1);
      m_pMainWnd->ShowWindow(SW_SHOW);
      m_pMainWnd->DragAcceptFiles();
      CCommandLineInfo cmdInfo;
      ParseCommandLine(cmdInfo);
      return TRUE;
      
}

IMPLEMENT_DYNCREATE(CMainFrame,CFrameWnd);

WinApp app;

i am getting the error

E:\VC++\MDIApplication\mdi.cpp(24) : error C2039: 'CreateObject' : is not a member of 'CDoc1'
        E:\VC++\MDIApplication\mdi.cpp(18) : see declaration of 'CDoc1'
E:\VC++\MDIApplication\mdi.cpp(24) : error C2039: 'classCDoc1' : is not a member of 'CDoc1'
        E:\VC++\MDIApplication\mdi.cpp(18) : see declaration of 'CDoc1'
E:\VC++\MDIApplication\mdi.cpp(24) : error C2039: 'CreateObject' : is not a member of 'CDoc1'
        E:\VC++\MDIApplication\mdi.cpp(18) : see declaration of 'CDoc1'
E:\VC++\MDIApplication\mdi.cpp(24) : error C2509: 'GetRuntimeClass' : member function not declared in 'CDoc1'
        E:\VC++\MDIApplication\mdi.cpp(18) : see declaration of 'CDoc1'
E:\VC++\MDIApplication\mdi.cpp(28) : error C2065: 'ar' : undeclared identifier
E:\VC++\MDIApplication\mdi.cpp(31) : error C2509: 'GetMessageMap' : member function not declared in 'CDoc1'
        E:\VC++\MDIApplication\mdi.cpp(18) : see declaration of 'CDoc1'
E:\VC++\MDIApplication\mdi.cpp(32) : error C2248: 'OnFileNew' : cannot access protected member declared in class 'CWinApp'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(4166) : see declaration of 'OnFileNew'
E:\VC++\MDIApplication\mdi.cpp(33) : error C2248: 'OnFileOpen' : cannot access protected member declared in class 'CWinApp'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(4167) : see declaration of 'OnFileOpen'
E:\VC++\MDIApplication\mdi.cpp(38) : error C2039: 'classCDoc1' : is not a member of 'CDoc1'
        E:\VC++\MDIApplication\mdi.cpp(18) : see declaration of 'CDoc1'
E:\VC++\MDIApplication\mdi.cpp(49) : error C2084: function 'class CObject *__stdcall CMainFrame::CreateObject(void)' already has a body
E:\VC++\MDIApplication\mdi.cpp(49) : error C2374: 'public: static struct CRuntimeClass const CMainFrame::classCMainFrame' : redefinition; multiple initialization
        E:\VC++\MDIApplication\mdi.cpp(13) : see declaration of 'public: static struct CRuntimeClass const CMainFrame::classCMainFrame'
E:\VC++\MDIApplication\mdi.cpp(49) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.
0
Comment
Question by:VenkateshArchana
  • 5
  • 3
10 Comments
 
LVL 5

Expert Comment

by:Xper4net
ID: 34171885
You'd better use App wizard.

First strange line :       DECLARE_DYCREATE(CDoc1);

It would be :       DECLARE_DYNCREATE(CDoc1);
Then you use a message map on CDoc1 without declaring it in class scope with :

DECLARE_MESSAGE_MAP()

In summary, your CDoc1 class would be :

class CDoc1:public CDocument
{
      void serialize(CArchive &a);
      DECLARE_DYNCREATE(CDoc1);
      DECLARE_MESSAGE_MAP() ;
};
0
 

Author Comment

by:VenkateshArchana
ID: 34172073
no i am not getting the output
0
 

Author Comment

by:VenkateshArchana
ID: 34172100
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/MDIApplication.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

getting following error
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 

Author Comment

by:VenkateshArchana
ID: 34172163
compile and linking are fine no error but i get debug  assertion failed
0
 
LVL 5

Expert Comment

by:Xper4net
ID: 34172436
Just remark that message map implementation is not done for WinApp.

Add the following if not already done:

BEGIN_MESSAGE_MAP(WinApp,CWinApp)
END_MESSAGE_MAP()

But I don't think assertion comes from that. Please let me know what line is pointed out by assertion (click on [Retry], it will point on source line)
0
 

Author Comment

by:VenkateshArchana
ID: 34173257
when i press retry i get this error
MDIApplication.exe has encountered a problem and needs to close.  We are sorry for the inconvenience.
0
 
LVL 5

Accepted Solution

by:
Xper4net earned 50 total points
ID: 34173362
Ok, it means that you'r not runinng from debugger.
 
I just see that you don't have any childframe. That what is missing.

Just add :
class CChildFrame : public CMDIChildWnd
{
      DECLARE_DYNCREATE(CChildFrame)
public:
      CChildFrame() {}
      virtual ~CChildFrame() {}
protected:
      DECLARE_MESSAGE_MAP()
};
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)

BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
END_MESSAGE_MAP()

And then fix your multi doc template initialization:

AddDocTemplate(new CMultiDocTemplate(IDR_MENU1,RUNTIME_CLASS(CDoc1),RUNTIME_CLASS(CChildFrame),RUNTIME_CLASS(CEditView)));


0
 

Author Comment

by:VenkateshArchana
ID: 34283936
i have changed the code and works well
0
 
LVL 40

Expert Comment

by:evilrix
ID: 34824145
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question