Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MDI form

Posted on 2000-04-13
10
Medium Priority
?
259 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
Independent Software Vendors: 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:Vinayak Kumbar
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 100 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

971 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