PDA

Click to See Complete Forum and Search --> : Menus and visibility...


crptcblade
Feb 5th, 2003, 06:48 AM
How is it that menus are made visible/invisible in C++? Do you just use RemoveMenu/InsertMenu, and keep track of the menu's position when its removed, or is there an easier way?

:)

Jop
Feb 5th, 2003, 08:45 AM
I remember from a long time ago when I wrote my own dynamic menu in VB using the API that it had some flags like visible etc.
But I'm not really sure :rolleyes:

crptcblade
Feb 5th, 2003, 08:50 AM
Thanks, I'm using this for VB, as a matter of fact. I'll take another look through the docs then.

:)

crptcblade
Feb 5th, 2003, 09:07 AM
Nope, it would appear not.

crptcblade
Feb 6th, 2003, 06:42 AM
Okay, I've got jim mcnamara over at galahtech, and he said that I can use SetWindowLong to add/remove the WS_VISIBLE property once I have the hWnd of the menu. So, anyone know how to get that?

:)

crptcblade
Feb 7th, 2003, 04:36 PM
Oh now, don't be shy...

crptcblade
Feb 9th, 2003, 02:49 PM
One last bump...;)

Jop
Feb 9th, 2003, 06:44 PM
Hi, I'm in a hurry now, so I can't go into detail, but the use of SetWindowLong is relativly simple.

You should get the style of the menu first (with GetWindowLong), then modify the result of GetWindowLong, and set the modified style with SetWindowLong

It has to be something like this:

DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE);
dwStyle = dwStyle | WS_VISIBLE; //Not sure if it should be | or & , I'm too tired :) but I think this is the right way...
SetWindowLong(hWnd, GWL_STYLE , dwStyle);


Something like that... If you need more help I can probably help you tomorrow :)

crptcblade
Feb 9th, 2003, 07:13 PM
Yeah, it wasn't the actual changing of the style that was bugging me, it was how to get the hWnd of a menu. Everything else I have a pretty good grip on.

:)

Jop
Feb 10th, 2003, 03:16 PM
I've been looking for you but I couldn't find any info on how to hide a menu-item (only with MFC), maybe just try passing the HMENU handle of the menu-item (Use GetMenu and then GetSubMenu to get it), but I think it won't work.. If I have time I'll try to find out for ya :)

crptcblade
Feb 10th, 2003, 03:24 PM
I gave the HMENU handle a shot, just out of desperation, and it had no effect.

It would be great if you could find something. I've been sifting through MSDN and google and have found nothing. I don't mind just using RemoveMenu to "hide" it and just keep track of what position the menu had, but if there is a better way, I'd rather go with that.

:)

Jop
Feb 10th, 2003, 03:46 PM
Yeah I've been looking for an hour or so... I still think there must be some way though... well removing and readding is possible of course, maybe that's how the VB & MFC function do it?

I'll keep you updated if I find something, made me curious :D