Solved

mdi application

Posted on 2010-11-19
10
1,014 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
Comment Utility
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
Comment Utility
no i am not getting the output
0
 

Author Comment

by:VenkateshArchana
Comment Utility
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
 

Author Comment

by:VenkateshArchana
Comment Utility
compile and linking are fine no error but i get debug  assertion failed
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 5

Expert Comment

by:Xper4net
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
i have changed the code and works well
0
 
LVL 40

Expert Comment

by:evilrix
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now