SM
2010-04-16 13:18:10 UTC
Hi All,
I have menu like below in the resource file
File
Option1
Option2
Option3
------------(menu separator)
Option4
-------------
Exit
During run time i need to add a new menu "Option5" before "Option4",
new menu will be like below
File
Option1
Option2
Option3
------------(menu separator)
Option5->Option6
Option7
Option4
-------------
Exit
For this i looped through the menu items using GetMenuItemCount for
getting the position to insert new menu
int menuCount = GetMenuItemCount(fileMenu);
int menuPosToInsert =0;
for(int i=0;i<menuCount ;i++)
{
if(GetMenuItemID(fileMenu,i) == MF_SEPARATOR)
{
menuPosToInsert=i;
}
}
GetMenuItemID(fileMenu,i) for separator is always returning 0 only,
so changed the code like below
if(GetMenuItemID(fileMenu,i) == 0)
after this, i used insertmenu to add the new menu item and it's
working fine.
Is the above approach ok for adding new menu item? i.e finding the
menu separator
Thanks,
Sony
I have menu like below in the resource file
File
Option1
Option2
Option3
------------(menu separator)
Option4
-------------
Exit
During run time i need to add a new menu "Option5" before "Option4",
new menu will be like below
File
Option1
Option2
Option3
------------(menu separator)
Option5->Option6
Option7
Option4
-------------
Exit
For this i looped through the menu items using GetMenuItemCount for
getting the position to insert new menu
int menuCount = GetMenuItemCount(fileMenu);
int menuPosToInsert =0;
for(int i=0;i<menuCount ;i++)
{
if(GetMenuItemID(fileMenu,i) == MF_SEPARATOR)
{
menuPosToInsert=i;
}
}
GetMenuItemID(fileMenu,i) for separator is always returning 0 only,
so changed the code like below
if(GetMenuItemID(fileMenu,i) == 0)
after this, i used insertmenu to add the new menu item and it's
working fine.
Is the above approach ok for adding new menu item? i.e finding the
menu separator
Thanks,
Sony