Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1104903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:32:56+00:00 2026-05-17T01:32:56+00:00

Have created a ATL COM project through which I am inserting Menu Items to

  • 0

Have created a ATL COM project through which I am inserting Menu Items to The rightclick menu like this:

STDMETHODIMP CSimpleShlExt::QueryContextMenu (
                      HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd,
                      UINT uidLastCmd, UINT uFlags )
{
    gHMenu=hmenu;
    UINT uCmdID = uidFirstCmd;

    // If the flags include CMF_DEFAULTONLY then we shouldn't do anything.

    if ( uFlags & CMF_DEFAULTONLY )
        return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 0 );

    InsertMenu ( hmenu, uMenuIndex,  MF_BYPOSITION, uCmdID++, _T("Connect To Server") );
    uMenuIndex++;
    InsertMenu ( hmenu, uMenuIndex, MF_BYPOSITION, uCmdID++,
               _T("DisConnect From Server") );
    return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 2 );
}

Now I wan to Disable the Connect submenu as soon as the user clicks on it and for this I am using EnableSubMenuItem ,

STDMETHODIMP CSimpleShlExt::InvokeCommand ( LPCMINVOKECOMMANDINFO pCmdInfo )
{
    // If lpVerb really points to a string, ignore this function call and bail out.
    if ( 0 != HIWORD( pCmdInfo->lpVerb ) )
        return E_INVALIDARG;


    switch ( LOWORD( pCmdInfo->lpVerb) )
        {
        case 0:
            {

            TCHAR szMsg [MAX_PATH + 32];

            wsprintf ( szMsg, _T("The selected file was:\n\n%s"), m_szFile );

            MessageBox ( pCmdInfo->hwnd, "Connected", _T("SimpleShlExt"),
                         MB_ICONINFORMATION );

             //InsertMenu ( hmenu, uMenuIndex, MF_STRING | MF_BYPOSITION, uCmdID++, _T("Connect => NDS") );
            //EnableMenuItem(gHMenu,0,MF_GRAYED);

Edit:

EnableMenuItem(gHMenu,0,MF_DISABLED | MF_GRAYED | MF_BYPOSITION);


            return S_OK;
            }
            break;

.....
....
...
}

But this is not helping with disabling the Menu Item. What am I doing Wrong??

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:32:57+00:00Added an answer on May 17, 2026 at 1:32 am

    Try this:

    EnableMenuItem(gHMenu,ITEM_ID,MF_DISABLED | MF_GRAYED);
    

    ITEM_ID should be the resource ID of the menu item.

    Or:

    EnableMenuItem(gHMenu,ITEM_POSITION,MF_DISABLED | MF_GRAYED | MF_BYPOSITION);
    

    where ITEM_POSITION is the zero-indexed position of the menu item.

    Note that after calling EnableMenuItem, you may need to call DrawMenuBar to ensure that the display has been updated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a Windows NT service, which exports a COM interface using ATL (out-of-proc
I have created a COM dll using ATL. When I attempt to use it
I have a C++ DLL project which is created in VS 2010. It is
I have a ATL COM service exe (MyService.exe), which compiles and runs fine. If
i have a invitation table. Like this; Email CreateDate a@gmail.com 2011-03-04 10:10:46.273 b@gmail.com 2011-03-10
I have rephrased this question. When .net objects are exposed to COM Clients through
I have an ATL COM object which needs to expose a collection of other
I have a custom button control created using ATL. This control is used by
I have a ATL COM component method which has an [out] BSTR* parameter. I
I have created a Shell Extension using ATL COM Object . But during creation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.