Dynamically changing the menu 
Author Message
 Dynamically changing the menu

Hi,

I read some names from tools from the registry and want to place them in the
tools menu. I like to do this at startup time. When I do this in the
OnCreate function from the main frame.

the following function reads the values (using an CRegistry class which is
not relevant here) and adds them to the tools menu.

When I call the function below from a menuitem after the program is started
it works fine. But at startup I call this function from within the OnCreate
function it doesn't work! Any ideas?

Thanks,

Remon

void CMainFrame::CreateToolsMenu()
{
 CRegistry Registry;
 CString strKey = "Software\\Remon\\Programmers Code Editor\\Tools";
 CString strCurrentKey;
 CString strMenuValue;
 CString strTemp;
 CMenu* pMenu = GetMenu()->GetSubMenu(3);
 int nIndex = 0;
 while (pMenu->DeleteMenu(MF_BYCOMMAND, ID_TOOLS_TOOL1 + nIndex))
  nIndex++;
 nIndex = 0;
 while (1)
 {
  strCurrentKey.Format("MenuText_%d", nIndex);
  if (!Registry.LoadKey(strKey, strCurrentKey, strMenuValue))
   break;
  if (nIndex == 0)
   pMenu->AppendMenu(MF_SEPARATOR);
  strTemp.Format("%d   ", nIndex + 1);
  strMenuValue = "&" + strTemp + strMenuValue + "\tCtrl+" + strTemp;
  pMenu->AppendMenu(MF_STRING, ID_TOOLS_TOOL1 + nIndex, strMenuValue);
  nIndex++;
 }
 DrawMenuBar();

Quote:
}



Thu, 31 Aug 2000 03:00:00 GMT  
 Dynamically changing the menu

Hi R. Spekreijse

I think the following sample might help you.
DYNAMENU: Dynamically Updates Menus
Click to open or copy the DYNAMENU project files.

Charles Steinhardt[MVP]



Fri, 01 Sep 2000 03:00:00 GMT  
 Dynamically changing the menu

Hi

I think u are calling this function too soon in OnCreate(); suspect
DrawMenuBar() particulary.
Try calling it from App::InitInstance() after the doc-template-stuff
created by AppWizard.

Berndus

Quote:

> ...
> When I call the function below from a menuitem after the program is
started
> it works fine. But at startup I call this function from within the
OnCreate
> function it doesn't work! Any ideas?
> ...
> > void CMainFrame::CreateToolsMenu()
> {
>   ...
>  DrawMenuBar();
> }



Fri, 01 Sep 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Dynamically change a menu label

2. @@@ Dynamically change IE4 menu/toolbar?

3. URGENT! Dynamically change File menu text

4. Dynamically change menu text

5. Dynamically changing menu in MDI app

6. Dynamically change caption of a menu

7. Dynamically changing top-level menu in SDI app?

8. MDI Menus - how to change dynamically?

9. Dynamically changing menus in an MDI application

10. dynamically changing MDI MainFrame menu

11. change the menu prompt dynamically

12. change menu prompt dynamically

 

 
Powered by phpBB® Forum Software