Re: How to Disable Menu Item by Don
Don
Thu Aug 21 19:10:21 CDT 2003
I was able to get a little further with your suggestion.
Using
SendMessage( hMenu, TB_ENABLEBUTTON, ID_FILE, FALSE),
I was able to disable the first submenu. I would like to
disable some items under the 'File' submenu. How do I get
the handle to the 'File' submenu? I tried GetWindow(
hMenu, GW_CHILD ). I even tried GetDlgItem( hMenu,
ID_FILE ) which I knew wouldn't work.
Thanks again,
Don
>-----Original Message-----
>I had the same issue just recently in an app that I am
>working on. Menu bars are really just command bars.
>Each menu item is just a button with a popup window
>attached. The following will disable a menu item on
>the menu bar.
>
>SHMENUBARINFO mbi;
>// Set the SHMENUBARINFO values (removed for clarity)
>
> if ( ::SHCreateMenuBar(&mbi) )
>{
> // Obviously, passing FALSE disables the button and
> // TRUE enables the button. wMenuItemId is the
> // command ID associated with the submenu.
>
> BOOL fEnable = FALSE;
>
> ::SendMessage(
> mbi.hwndMB,
> TB_ENABLEBUTTON,
> (WPARAM) wMenuItemId,
> (LPARAM) MAKELONG(fEnableItem, 0)
> );
>}
>
>Darron
>
>
>
>"Don Woods" <drwoods@attglobal.net> wrote in message
>news:090701c36808$b561f9f0$a001280a@phx.gbl...
>> I created a menubar with SHCreateMenuBar. I can
disable
>> the whole bar by using SHFindMenuBar and using the
>> returned handle in a call to EnableWindow( hMenu,
FALSE );
>>
>> What I'd prefer to do is disable particular items.
I've
>> tried using hMenu in EnableMenuItem like this:
>>
>> EnableMenuItem( hMenu, ID_FILE_XXXX, MF_GRAYED ), but
it
>> doesn't work. I also tried by position:
>>
>> EnableMenuItem( hMenu, 0, MF_BYPOSITION | MF_GRAYED ),
>> again with no luck. I would have thought that would
have
>> grayed out something, but everything was still
>> available. Is it possible to gray out these popup
menus?
>>
>> Thanks,
>> Don
>
>
>.
>