0
votes

In my MFC app I create an context menu:

CString strName;
strName.LoadString(IDS_EDIT_MENU);
GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT);

This menu is described in a resource file as usual:

IDR_POPUP_EDIT MENU
BEGIN
POPUP "Edit"
BEGIN
MENUITEM "Cu&t\tCtrl+X",                ID_EDIT_CUT
MENUITEM "Copy\tCtrl+C",                ID_EDIT_COPY
MENUITEM "&Paste\tCtrl+V",              ID_EDIT_PASTE
END
END

Once in the code I show this menu in a right button handler:

theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);

It has icons 16x16 and it is shown good. But then I added a floating toolbar, which has icons 32x32.

if (!m_notesToolbar.CreateEx(this,
    TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,
    CRect(1, 1, 1, 1), ID_NOTES_TOOLBAR) ||
    !m_notesToolbar.LoadToolBar(IDR_NOTES_TOOLBAR))
{
    TRACE0("Failed to create toolbar\n");
    return -1;
}

m_notesToolbar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_notesToolbar);

So, now the context menu also has height of items 32 pixels. Why? And how can I have these GUI objects of different heights?

good height

bad height

1

1 Answers

1
votes

Doing this requires an ownerdraw menu. Than you can set a menu item height.

For owner draw menus here is a good sample (its old but should work).