Nuno Nuno - 3 months ago 45
C++ Question

How to hide/collapse main menu in a win32/mfc application

I always been interested on how we can accomplish this (hide/show the main menu using the alt key), and now some applications do this very often. One that really please me is the visual studio 2010 with this plugin:
http://visualstudiogallery.msdn.microsoft.com/bdbcffca-32a6-4034-8e89-c31b86ad4813?SRC=VSIDE

(firefox also do this, but i think that is in a different way)

Can anyone explain me how this can be achieved or if you known of any sample project that demonstrate this please tell me.

(what i can see in some replies here in stack is that we have to destroy the menu when is to hide and create it when is to show?! but this seems a bit bad solution...)

Thanks

Answer

The SetMenu function lets you add/remove the menu from the window. It does not destroy the menu.

Note that most applications which have the dynamic menu hide/show behavior are not really showing a menu. They're showing a custom control that looks like a menu.