A
Asheesh
Hi All,
I'd appreciate if someone could provide me a better way of doing this.
I need to show a different menubar for a particular screen. The interesting
part is that the U.I of the Form is the same but when the app runs in a
different mode, the same screen is presented with a different menubar.
For this I'm dynamically creating the Menubar based on the Mode in which my
application is running.
My menubar is something like this Mode 1:
File Mode Lang Find Rep
My menubar for Mode 2 is
File Mode Opt Lang Find Hist
Now in case of Opt I've a lot of other sub-menus as well.
What I've done is declared all my menuitems in my class level with a private
scope. Now when the user selects a particular mode, I dynamically create
all the menuitems/submenuitems and assign the mainmenu to the Form's Menu.
I do this whenever the user changes the Mode. This approach works fine, but
everytime I've to clear the previous menuitems, and then create the new
menubar.
It's mnuMain.menuitems.clear();
CreateNewModeMenu();
But taking this approach leads to so many menuitem objects created everytime
I change the mode of my application. In fact when I look at the available
memory, it reduces to quite an extent everytime I perform the mode
operation.
I want to know that are the menuitems garbage collected when I call the
mnuMain.menuitems.clear() method?
Is there another way where I can prevent creation and deletion of so many
menuitems again and again so that only once do I create a menubar for each
mode, and just replace the menu for the form?
Please help...
Regards,
Asheesh
I'd appreciate if someone could provide me a better way of doing this.
I need to show a different menubar for a particular screen. The interesting
part is that the U.I of the Form is the same but when the app runs in a
different mode, the same screen is presented with a different menubar.
For this I'm dynamically creating the Menubar based on the Mode in which my
application is running.
My menubar is something like this Mode 1:
File Mode Lang Find Rep
My menubar for Mode 2 is
File Mode Opt Lang Find Hist
Now in case of Opt I've a lot of other sub-menus as well.
What I've done is declared all my menuitems in my class level with a private
scope. Now when the user selects a particular mode, I dynamically create
all the menuitems/submenuitems and assign the mainmenu to the Form's Menu.
I do this whenever the user changes the Mode. This approach works fine, but
everytime I've to clear the previous menuitems, and then create the new
menubar.
It's mnuMain.menuitems.clear();
CreateNewModeMenu();
But taking this approach leads to so many menuitem objects created everytime
I change the mode of my application. In fact when I look at the available
memory, it reduces to quite an extent everytime I perform the mode
operation.
I want to know that are the menuitems garbage collected when I call the
mnuMain.menuitems.clear() method?
Is there another way where I can prevent creation and deletion of so many
menuitems again and again so that only once do I create a menubar for each
mode, and just replace the menu for the form?
Please help...
Regards,
Asheesh