Deleting menus on exit... - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Deleting menus on exit...

SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
I'm working on an application that creates its main menu using "CreateMenu()" before the window is created. This way I can stay away from VS2005's bloated resource files. The thing is, when I close out the program, I want to know that all of my resources are freed to avoid memory-leaks, but I am not sure if I am freeing the menu properly or not. I am using "DeleteMenu()" to attempt to delete the entire menu and sub-menus in one quick, easy call. The MSDN says that "DeleteMenu()" will do this, but I am not sure whether or not I am calling it correctly to do so.
[code]
//See if the menu needs freeing
if(this->hMainMenu != 0)
DeleteMenu(this->hMainMenu, 0, MF_BYPOSITION);
[/code]
That is in the class method for cleaning up my prorgam. I am assuming that specifying position zero will delete everything from that position on. Is this correct?

*EDIT*

After a few hours of searching I found out that to free a menu, you must call "DestroyMenu(HMENU)". This takes care of all items on the menu, but not sub-menus. You should destroy all sub-menus first, then the parent menu.

-[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
Sign In or Register to comment.