Solved

mdi application

Posted on 2010-11-19
10
1,091 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
Technology Partners: 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
  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 clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

631 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