Sign in to follow this  
GDMichael

MFC MDI Menu Problem?

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this