Click here to Skip to main content
15,896,727 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: List Box & Rich Edit box Pin
Suresh H18-Feb-07 20:50
Suresh H18-Feb-07 20:50 
AnswerRe: List Box & Rich Edit box Pin
prasad_som18-Feb-07 22:00
prasad_som18-Feb-07 22:00 
GeneralRe: List Box & Rich Edit box Pin
Suresh H18-Feb-07 22:48
Suresh H18-Feb-07 22:48 
AnswerRe: List Box & Rich Edit box Pin
prasad_som18-Feb-07 22:52
prasad_som18-Feb-07 22:52 
AnswerRe: List Box & Rich Edit box Pin
David Crow16-Feb-07 2:52
David Crow16-Feb-07 2:52 
QuestionWindows Menus and the WM_MENUCOMMAND message Pin
Martin081515-Feb-07 22:41
professionalMartin081515-Feb-07 22:41 
QuestionRe: Windows Menus and the WM_MENUCOMMAND message Pin
prasad_som16-Feb-07 1:51
prasad_som16-Feb-07 1:51 
AnswerRe: Windows Menus and the WM_MENUCOMMAND message Pin
Martin081516-Feb-07 2:22
professionalMartin081516-Feb-07 2:22 
Yes - here's some "reduced" code:

1. the creation of a popup menu:

DWORD       style       = 0;
CMenu       *popup      = (CMenu *) NULL;
MENUINFO    menuInfo;   // see below (1)

memset( &menuInfo, 0x0, sizeof( MENUINFO ) );   // (1)

// create the new menu object
//
popup   = new CMenu();

// create the new popup menu
//
if ( ( popup != NULL ) && ( popup->CreatePopupMenu() == TRUE ) )
{
    // initialize the menu info structure to get its dwStyle member
    //
    menuInfo.cbSize = sizeof( MENUINFO );
    menuInfo.fMask  = MIM_STYLE;

    if ( popup->GetMenuInfo( &menuInfo ) == TRUE )
    {
        style   = menuInfo.dwStyle;

        // (re)initialize the menu info structure to change only its dwStyle member
        //
        memset( &menuInfo, 0x0, sizeof( MENUINFO ) );

        menuInfo.cbSize     = sizeof( MENUINFO );
        menuInfo.fMask      = MIM_APPLYTOSUBMENUS | MIM_STYLE;
        menuInfo.dwStyle    = style | MNS_NOTIFYBYPOS;

        if ( popup->SetMenuInfo( &menuInfo ) == TRUE )
        {
            tcl_publishResult( ip, (char *) create_popup_token( popup ) );
            return TCL_OK;
        }
    }
}

system_error_message( ip, "couldn't create popup menu" );

if ( popup != NULL )
{
    delete popup;
}

return TCL_ERROR;


2. the insertion of a created popup menu:

int             itemPosition    = 0;
char            *label          = (char *) NULL;
CWnd            *root           = (CWnd *) NULL;
CMenu           *menu           = (CMenu *) NULL,
                *popup          = (CMenu *) NULL;
MENUITEMINFO    menuInfo;       // see below (1)

Menu_if_tcl_MenuItem_s_t    *menuItem   = (Menu_if_tcl_MenuItem_s_t *) NULL;

memset( &menuInfo, 0x0, sizeof( MENUITEMINFO ) );   // (1)

menuInfo.cbSize = sizeof( MENUITEMINFO );

// get the popup menu pointer and the label ...
//
// ...
//

// access the main window
//
root    = AfxGetApp()->m_pMainWnd;
menu    = get_owning_menu( ip, root->GetMenu(), positionsList, itemPosition );

if ( ( menu != NULL ) &&
     ( itemPosition != -1 ) &&
     ( (UINT) itemPosition <= menu->GetMenuItemCount() ) )
{
    if ( menu->InsertMenu( itemPosition, MF_BYPOSITION | MF_STRING | MF_POPUP, (UINT) popup->m_hMenu, label ) == TRUE )
    {
        menuItem    = create_menu_item( PopupMenuItem, "" );

        menuInfo.fMask      = MIIM_DATA | MIIM_STATE;
        menuInfo.fState     = MFS_ENABLED;
        menuInfo.dwItemData = (ULONG_PTR) menuItem;

        if ( menu->SetMenuItemInfo( itemPosition, &menuInfo, TRUE ) == TRUE )
        {
            root->DrawMenuBar();
            tcl_publishResult( ip, menuItem->token );
            return TCL_OK;
        }
    }
}

system_error_message( ip, "couldn't insert popup menu" );
return TCL_ERROR;


After using the MNS_NOTIFYBYPOS flag and setting the MENUINFO of the created popup menu I expected to get WM_MENUCOMMAND messages, when selecting menu items, but I always get WM_COMMANDS.

Thanks for your reply!

Best Regards,

Martin Lemburg
AnswerRe: Windows Menus and the WM_MENUCOMMAND message Pin
prasad_som16-Feb-07 3:08
prasad_som16-Feb-07 3:08 
QuestionRe: Windows Menus and the WM_MENUCOMMAND message Pin
Martin081516-Feb-07 3:56
professionalMartin081516-Feb-07 3:56 
AnswerRe: Windows Menus and the WM_MENUCOMMAND message Pin
prasad_som16-Feb-07 5:00
prasad_som16-Feb-07 5:00 
GeneralRe: Windows Menus and the WM_MENUCOMMAND message Pin
Martin081516-Feb-07 6:31
professionalMartin081516-Feb-07 6:31 
QuestionDebugging capability Pin
mt_samiei15-Feb-07 22:39
mt_samiei15-Feb-07 22:39 
AnswerRe: Debugging capability Pin
Cedric Moonen15-Feb-07 22:50
Cedric Moonen15-Feb-07 22:50 
GeneralRe: Debugging capability Pin
mt_samiei15-Feb-07 23:03
mt_samiei15-Feb-07 23:03 
GeneralRe: Debugging capability Pin
NiceNaidu15-Feb-07 23:07
NiceNaidu15-Feb-07 23:07 
Questionkbhit() Question Pin
Programm3r15-Feb-07 20:57
Programm3r15-Feb-07 20:57 
AnswerRe: kbhit() Question Pin
Programm3r15-Feb-07 21:10
Programm3r15-Feb-07 21:10 
GeneralRe: kbhit() Question Pin
prasad_som15-Feb-07 22:29
prasad_som15-Feb-07 22:29 
AnswerRe: kbhit() Question [modified] Pin
prasad_som15-Feb-07 21:54
prasad_som15-Feb-07 21:54 
AnswerRe: kbhit() Question Pin
David Crow16-Feb-07 3:19
David Crow16-Feb-07 3:19 
QuestionMessagebox Question Pin
Programm3r15-Feb-07 20:47
Programm3r15-Feb-07 20:47 
AnswerRe: Messagebox Question Pin
toxcct15-Feb-07 20:52
toxcct15-Feb-07 20:52 
GeneralRe: Messagebox Question Pin
Programm3r15-Feb-07 20:57
Programm3r15-Feb-07 20:57 
QuestionENTER and SHIFT+ENTER in simple text edit box (EDITTEXT) Pin
deivakumar15-Feb-07 20:10
deivakumar15-Feb-07 20:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.