Jump to content
  • Advertisement
Sign in to follow this  

MFC MDI Menu Problem?

This topic is 4492 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All, I have found some strange problem. When I create a MDI program. I create a menu called "IDR_MyFrame". and when the men structure is : File -> Exit(SubMenu) It cannot work correct. But if I add one more "Super Menu", like that: File -> Exit(SubMenu) Edit -> Copy(SubMenu) It will become workable, why? Here is my program: /* */ #include <afxwin.h> #include <afxtempl.h> #include <afxext.h> #include "MyFrame.h" class MyDocument : public CDocument { MyDocument(){} ~MyDocument(){} DECLARE_DYNCREATE(MyDocument) DECLARE_MESSAGE_MAP() }; IMPLEMENT_DYNCREATE(MyDocument, CDocument) BEGIN_MESSAGE_MAP(MyDocument, CDocument) END_MESSAGE_MAP() class MyMDIChild : public CMDIChildWnd { MyMDIChild(){} ~MyMDIChild(){} DECLARE_DYNCREATE(MyMDIChild) DECLARE_MESSAGE_MAP() }; IMPLEMENT_DYNCREATE(MyMDIChild, CMDIChildWnd) BEGIN_MESSAGE_MAP(MyMDIChild, CMDIChildWnd) END_MESSAGE_MAP() class MyFrame : public CMDIFrameWnd { public: MyFrame(){} ~MyFrame(){} afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct) { if(CMDIFrameWnd::OnCreate(lpCreateStruct)) return -1; return 0; } DECLARE_DYNCREATE(MyFrame) DECLARE_MESSAGE_MAP() }; IMPLEMENT_DYNCREATE(MyFrame, CMDIFrameWnd) BEGIN_MESSAGE_MAP(MyFrame, CMDIFrameWnd) ON_WM_CREATE() END_MESSAGE_MAP() class MyView : public CScrollView { public: MyView(){} ~MyView(){} //MyView::OnCreate afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CScrollView::OnCreate(lpCreateStruct) == -1) return -1; CSize DCSize(800, 800); SetScrollSizes(MM_TEXT,DCSize); return 0; } //MyView::OnDraw afx_msg void OnDraw(CDC * aDC) { MyDocument *doc = (MyDocument *)GetDocument(); CView::OnDraw(aDC); } DECLARE_DYNCREATE(MyView) DECLARE_MESSAGE_MAP() }; IMPLEMENT_DYNCREATE(MyView, CScrollView) BEGIN_MESSAGE_MAP(MyView, CScrollView) ON_WM_CREATE() END_MESSAGE_MAP() class MyApp : public CWinApp { public: BOOL InitInstance() { CMultiDocTemplate *aDocTemplate; aDocTemplate = new CMultiDocTemplate( IDR_ChildFrame, RUNTIME_CLASS(MyDocument), RUNTIME_CLASS(MyMDIChild), RUNTIME_CLASS(MyView)); AddDocTemplate(aDocTemplate); MyFrame * Frame = new MyFrame; m_pMainWnd = Frame; Frame->LoadFrame(IDR_MyFrame); Frame->ShowWindow(SW_SHOW); // RegisterShellFileTypes(); return TRUE; } DECLARE_MESSAGE_MAP() }; BEGIN_MESSAGE_MAP(MyApp, CWinApp) END_MESSAGE_MAP() MyApp a_app;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!