Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

mdi application

Posted on 2010-11-19
10
Medium Priority
?
1,120 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

  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 …
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 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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

885 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