Solved

mdi application

Posted on 2010-11-19
10
1,073 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

738 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