Solved

MDI form

Posted on 2000-04-13
10
251 Views
Last Modified: 2013-11-20
Hi,
   I am creating an MDI form,but i dont want the menu to be there in my application. Is it possible to do this? I am connecting my application to a database, but i want to achieve it without menus

Thanx,
Thiru
0
Comment
Question by:thirumaran
  • 5
  • 4
10 Comments
 
LVL 5

Expert Comment

by:proskig
ID: 2711502
Steps to Create MDI Application that Has No Menu Bar
Generate an MDI application with AppWizard. Do not delete the IDR_MAINFRAME menu resource. If you have an application that was not generated with AppWizard, do not delete the corresponding main menu resource. Leaving the menu resource is required to avoid assertion failures in the MFC code.


Delete menu resources associated with MDI child windows (IDR_xxxTYPE). They are not used. By deleting them, you avoid a resource (memory) leak.


Override the PreCreateWindow() function for the CMainFrame class:

      BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
      {
         if(cs.hMenu!=NULL)
         {
             ::DestroyMenu(cs.hMenu);      // delete menu if loaded
             cs.hMenu = NULL;              // no menu for this window
         }

         return CMDIFrameWnd::PreCreateWindow(cs);
      }



Modify the code responsible for switching menus by overriding the LoadFrame() and OnCreateClient() methods of CMainFrame. This is necessary because MFC has already loaded and switched menus automatically. The following shows what must be done:

      // Overridden method declarations for CMainFrame

      BOOL LoadFrame( UINT nIDResource,
             DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,
             CWnd* pParentWnd = NULL, CCreateContext* pContext = NULL );
      BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs,
             CCreateContext* /*pContext*/);

      // Overridden method declarations for CMainFrame

      BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle,
             CWnd* pParentWnd, CCreateContext* pContext)
      {
          return CFrameWnd::LoadFrame(nIDResource,dwDefaultStyle,
              pParentWnd,pContext);
      }

      BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs,
              CCreateContext* /*pContext*/)
      {
          return CreateClient(lpcs,NULL);
      }



NOTE: Instead of calling the base class (CMDIFrameWnd) in the override of LoadFrame, you call its base class, CFrameWnd, instead. That way you can avoid the code that deals with MDI menus.
0
 

Author Comment

by:thirumaran
ID: 2711857
It is showing application error when this code is implemented.

Thiru
0
 
LVL 5

Expert Comment

by:proskig
ID: 2712728
Where? What is the error?
0
 

Author Comment

by:thirumaran
ID: 2714744
where to put the declarations fo the member functions LoadFrame and OnCreateClient.What are the access specifiers??Is it in MainFrame.h and the definition in .cpp file?

Thanx,
Thiru
0
 
LVL 8

Expert Comment

by:VinExpert
ID: 2714773
Hi,

U can use SetMenu(NULL) in the mainframe.
try it out.

VinExpert
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:thirumaran
ID: 2714806
where to put the declarations fo the member functions LoadFrame and OnCreateClient.What are the access specifiers??Is it in MainFrame.h and the definition in .cpp file?

Thanx,
Thiru
0
 
LVL 5

Accepted Solution

by:
proskig earned 25 total points
ID: 2714867
Yes,
by default files are MainFrame.h and MainFrame.cpp. These functions are virtual and public. The best way to add them is to use ClassWizard.
0
 

Author Comment

by:thirumaran
ID: 2714878
The error is shown in windows.cpp file , where theLoadFrame takes only 1 parameter,instead of 4 parameters.

Thanx,
Thiru
0
 
LVL 5

Expert Comment

by:proskig
ID: 2715330
LoadFrame is the member of CMainFrame - it is not global one. Can you send me your code by E-Mail - it will be easier.
proskig@hotmail.com
0
 

Author Comment

by:thirumaran
ID: 2715415
My code is working now. Thanx for ur help proskig

Thiru
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now