Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3670
Number of posts: 9122

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Deleting menus on exit... Posted by Sephiroth on 15 Jan 2009 at 11:33 AM
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.
//See if the menu needs freeing
if(this->hMainMenu != 0)
  DeleteMenu(this->hMainMenu, 0, MF_BYPOSITION);

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.

-Sephiroth



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.