Popup menu - Programmer

This is a discussion on Popup menu - Programmer ; I have designed a menu with 1 option in resource view. Say Select- >Optioin1 with id IDR_SECONDMENU. Then I'm modifying popup menu dynamically. Like adding Option2, Options3 and Option4 in Select menu in OnCreate() method of CMainFrm. Then I'm displaying ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Popup menu

  1. Popup menu

    I have designed a menu with 1 option in resource view. Say Select-
    >Optioin1 with id IDR_SECONDMENU.


    Then I'm modifying popup menu dynamically. Like adding Option2,
    Options3 and Option4 in Select menu in OnCreate() method of CMainFrm.

    Then I'm displaying this menu with TrackPopupMenu after Loading
    IDR_SECONDMENU using LoadMenu and getting 0th submenu from it.

    In the menu, only "Option 1" is displayed. "Option2", "Option3" and
    "Option4" are not being displayed. Why the 3 options added dynamically
    are not being displayed?

    One more thing, IDR_SECONDMENU is not the default menu for my frame.
    So I cant use GetMenu and SetMenu and change it. I need to use
    LoadMenu() only.

    How to show these 3 options added dynamically?

  2. Re: Popup menu

    On Thu, 22 May 2008 03:18:32 -0700 (PDT), james
    wrote:

    >I have designed a menu with 1 option in resource view. Say Select-
    >>Optioin1 with id IDR_SECONDMENU.

    >
    >Then I'm modifying popup menu dynamically. Like adding Option2,
    >Options3 and Option4 in Select menu in OnCreate() method of CMainFrm.
    >
    >Then I'm displaying this menu with TrackPopupMenu after Loading
    >IDR_SECONDMENU using LoadMenu and getting 0th submenu from it.
    >
    >In the menu, only "Option 1" is displayed. "Option2", "Option3" and
    >"Option4" are not being displayed. Why the 3 options added dynamically
    >are not being displayed?


    You are probably not adding the extra menu items correctly. Show us
    your code.

    >
    >One more thing, IDR_SECONDMENU is not the default menu for my frame.
    >So I cant use GetMenu and SetMenu and change it. I need to use
    >LoadMenu() only.
    >
    >How to show these 3 options added dynamically?


    -----------------------------------------
    To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

    Robert E. Zaret, eMVP
    PenFact, Inc.
    20 Park Plaza, Suite 400
    Boston, MA 02116
    www.penfact.com
    Useful reading (be sure to read its disclaimer first):
    http://catb.org/~esr/faqs/smart-questions.html

  3. Re: Popup menu


    wrote in message
    news:88na34dksa7858lhbtieild9qmgl6ivijt@4ax.com...
    > On Thu, 22 May 2008 03:18:32 -0700 (PDT), james
    > wrote:
    >
    >>I have designed a menu with 1 option in resource view. Say Select-
    >>>Optioin1 with id IDR_SECONDMENU.

    >>
    >>Then I'm modifying popup menu dynamically. Like adding Option2,
    >>Options3 and Option4 in Select menu in OnCreate() method of CMainFrm.
    >>
    >>Then I'm displaying this menu with TrackPopupMenu after Loading
    >>IDR_SECONDMENU using LoadMenu and getting 0th submenu from it.
    >>
    >>In the menu, only "Option 1" is displayed. "Option2", "Option3" and
    >>"Option4" are not being displayed. Why the 3 options added dynamically
    >>are not being displayed?

    >
    > You are probably not adding the extra menu items correctly. Show us
    > your code.


    I would say interpretion of "and getting 0th submenu from it" is the key to
    what's wrong. A popup with one ITEM (not option) doesn't have a submenu.
    So just LoadMenu(), then AppendMenu().

    - Sten



  4. Re: Popup menu

    On Jul 1, 5:16*pm, "Sten Westerback \(MVP SDK 2005-6 :\)"
    wrote:
    > wrote in message
    >
    > news:88na34dksa7858lhbtieild9qmgl6ivijt@4ax.com...
    >
    >
    >
    > > On Thu, 22 May 2008 03:18:32 -0700 (PDT), james
    > > wrote:

    >
    > >>I have designed a menu with 1 option in resource view. Say Select-
    > >>>Optioin1 with id IDR_SECONDMENU.

    >
    > >>Then I'm modifying popup menu dynamically. Like adding Option2,
    > >>Options3 and Option4 in Select menu in OnCreate() method of CMainFrm.

    >
    > >>Then I'm displaying this menu with TrackPopupMenu after Loading
    > >>IDR_SECONDMENU using LoadMenu and getting 0th submenu from it.

    >
    > >>In the menu, only "Option 1" is displayed. "Option2", "Option3" and
    > >>"Option4" are not being displayed. Why the 3 options added dynamically
    > >>are not being displayed?

    >
    > > You are probably not adding the extra menu items correctly. Show us
    > > your code.

    >
    > I would say interpretion of "and getting 0th submenu from it" is the key to
    > what's wrong. A popup with one ITEM (not option) doesn't have a submenu.
    > So just LoadMenu(), then AppendMenu().
    >
    > - Sten


    I'm doing in that way:

    Code:
    const INT CGdiHddPlugin::AppendPluginMenu( HMENU aMenu, HMODULE /
    *aModule*/ )
    {
    __LOG__;
    CGdiPlugin::AppendPluginMenu( aMenu );
    HMENU gdiMenu = GetSubMenu( aMenu, 1 );
    HMENU hddMenu = LoadMenu( m_DllModule,
    MAKEINTRESOURCE( ID_GDI_POPUP_MENU ) );
    HMENU subMenu = NULL;
    int count = GetMenuItemCount( hddMenu );
    TCHAR name[g_maxMenuName];
    for( int i=0; i(subMenu),
    name );
    }
    
    __LOG_RETURN__( eNoError );
    
    }

+ Reply to Thread