From: Larry on
Hi,

I have some difficulties understanding how to go about using
EnableMenuItem() function (I need to gray a menuitem)

BOOL EnableMenuItem(
HMENU hMenu,
UINT uIDEnableItem,
UINT uEnable
);

Now, I have the menu defined in an .rc and .h files like the following:

//resource.h
#define IDM_MENU 200
#define IDM_FILE_START 201
#define IDM_FILE_STOP 202

//resource.rc
#include "resource.h"

IDM_MENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "Start thread...", IDM_FILE_START
MENUITEM "Stop thread...", IDM_FILE_STOP
END
END


The menu is loaded into the main window thru the WNDCLASS:

..lpszMenuName = MAKEINTRESOURCE(IDM_MENU);


and I capture the system messages by using the classic window callback:

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
switch(message)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDM_FILE_START:
(...)
break;

case IDM_FILE_STOP:
(...)
break;
}
break;

default:
return DefWindowProc(hwnd, Message, wParam, lParam);
}
return 0;
}

Now when I get the IDM_FILE_START wParam thru the WM_COMMAND message how can
I disable the IDM_FILE_START menuitem by using the EnableMenuItem()
function?

thanks

From: David Lowndes on
> I have some difficulties understanding how to go about using
>EnableMenuItem() function (I need to gray a menuitem)

What exactly are you having difficulties with?

>Now when I get the IDM_FILE_START wParam thru the WM_COMMAND message how can
>I disable the IDM_FILE_START menuitem by using the EnableMenuItem()
>function?

Have you tried something like:

EnableMenuItem( GetMenu( hWnd ),
IDM_FILE_START,
MF_GRAYED | MF_BYCOMMAND );

Dave