Solved

MDI form

Posted on 2000-04-13
10
253 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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
 

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Whole sheet autoscrub still needed 19 50
abstract class with all non abstract mentods 6 76
sumHeights2  challenge 7 105
Fibonacci challenge 11 122
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: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 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