
Dynamic Menu Creation in MDI App
Look on: MVP VC++ FAQ: http://www.mvps.org/vcfaq/mfc/3.htm
--------------------
Quote:
>Subject: Re: Dynamic Menu Creation in MDI App
>Date: Fri, 16 May 2003 10:15:07 -0700
>Lines: 42
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
>Newsgroups: microsoft.public.vc.mfc,microsoft.public.vc.mfc.docview
>NNTP-Posting-Host: adeskout.autodesk.com 198.102.112.18
>Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
>Xref: cpmsftngxa06.phx.gbl microsoft.public.vc.mfc.docview:20843 microsoft.public.vc.mfc:375072
>X-Tomcat-NG: microsoft.public.vc.mfc.docview
>You have to modify the menu of the corresponding doctemplate. This menu
>handle is a public member of CMultiDoctemplate(m_hMenuShared).
>--
>Ajay Kalra [MVP - VC++]
>> Hello Netlanders,
>> I have to dynamically create a menu for my MDI App.When i use GetMenu() on
>> the OnCreate() handler in the CMainFrame class it gets the mainframe menu
>> i.e IDR_MAINFRAME.I want to modify the IDR_<appname>TYPE menu.If i modify
>it
>> using LoadMenu() in the OnCreate() Handler i dont see any change.What i
>have
>> to do to modify the menu and where to place the code.The code snippet is
>> int count;
>> char temp[13];
>> CMenu *pMenu = new CMenu();
>> CMenu *sMenu = new CMenu();
>> if(pMenu->LoadMenu(IDR_IETYPE))
>> pMenu = pMenu->GetSubMenu(3);
>> count = pMenu->GetMenuItemCount();
>> wsprintf(temp,"%d",count);
>> MessageBox(temp);
>> if(pMenu)
>> {
>> pMenu->AppendMenu(MF_STRING|MF_ENABLED,ID_MENU,"Naveen");
>> MessageBox("Menu Appended");
>> }
>> count = pMenu->GetMenuItemCount();
>> wsprintf(temp,"%d",count);
>> MessageBox(temp);
>> DrawMenuBar();
>> pMenu->DestroyMenu();
--
This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm