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

Re: How to Disable Menu Item by D

D
Thu Aug 21 18:25:19 CDT 2003

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



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
>
>
>.
>

Re: How to Disable Menu Item by D

D
Thu Aug 21 21:33:45 CDT 2003

Following the earlier example and assuming that:
1. the file menu has an id of IDM_FILE:
2. we want to disable the File->Save command (with id=IDM_FILE_SAVE)

HMENU hMenu = (HMENU) ::SendMessage(mbi.hwndMB, SHCMBM_GETSUBMENU, 0,
(LPARAM) IDM_FILE);
::EnableMenuItem(hMenu, IDM_FILE_SAVE, MF_BYCOMMAND | MF_GRAYED);

to enable it you would use:

::EnableMenuItem(hMenu, IDM_FILE_SAVE, MF_BYCOMMAND | MF_ENABLED);

I believe that you can also use GetSubMenu() instead of
SendMessage() with SHCMBM_GETSUBMENU but
you would need to try it out to be sure.

Darron


"Don Woods" <drwoods@attglobal.net> wrote in message
news:05ce01c36841$c69f56c0$a401280a@phx.gbl...
> 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



Re: How to Disable Menu Item by Don

Don
Fri Aug 22 09:45:13 CDT 2003

Darron,

That worked great (SendMessage). Couldn't get GetSubMenu
to work, but that's fine.

I was wondering what you use for reference for finding
these commands and functions? When I search the info
that came with eC++, I never find anything ;). Of course
I can find it after someone tells me it...

In my wildest dreams I never would have come up with an
SHCMBM_GETSUBMENU command message.

I think I'll start browsing the header files directly and
see what I find, and then use the online help.

Thanks,
Don
>-----Original Message-----
>Following the earlier example and assuming that:
>1. the file menu has an id of IDM_FILE:
>2. we want to disable the File->Save command (with
id=IDM_FILE_SAVE)
>
>HMENU hMenu = (HMENU) ::SendMessage(mbi.hwndMB,
SHCMBM_GETSUBMENU, 0,
>(LPARAM) IDM_FILE);
>::EnableMenuItem(hMenu, IDM_FILE_SAVE, MF_BYCOMMAND |
MF_GRAYED);
>
>to enable it you would use:
>
>::EnableMenuItem(hMenu, IDM_FILE_SAVE, MF_BYCOMMAND |
MF_ENABLED);
>
>I believe that you can also use GetSubMenu() instead of
>SendMessage() with SHCMBM_GETSUBMENU but
>you would need to try it out to be sure.
>
>Darron
>
>
>"Don Woods" <drwoods@attglobal.net> wrote in message
>news:05ce01c36841$c69f56c0$a401280a@phx.gbl...
>> 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
>
>
>.
>

Re: How to Disable Menu Item by D

D
Fri Aug 22 18:24:36 CDT 2003

I have a bunch of years developing apps on the desktop and
the PPC is not far removed, just more limited. Reference
wise, I use anything from msdn.microsoft.com to Visual Studio
.NET (ie MSDN library) to Google. One tip would be to
check out the ATL libraries included with the SDK. If you
can find the right class, you can usually find the functionality
you are looking for.

Darron


"Don Woods" <drwoods@attglobal.net> wrote in message
news:0ccb01c368bb$fe428050$a401280a@phx.gbl...
> Darron,
>
> That worked great (SendMessage). Couldn't get GetSubMenu
> to work, but that's fine.
>
> I was wondering what you use for reference for finding
> these commands and functions? When I search the info
> that came with eC++, I never find anything ;). Of course
> I can find it after someone tells me it...
>
> In my wildest dreams I never would have come up with an
> SHCMBM_GETSUBMENU command message.
>
> I think I'll start browsing the header files directly and
> see what I find, and then use the online help.
>
> Thanks,
> Don