Solved

MDI form

Posted on 2000-04-13
10
256 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
pre4 challenge 19 116
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 1,716
Not needed 13 134
JQuery serialize and unserialize 8 275
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

710 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