win32 - how can resize an ownerdraw menu item?
Oct 21, 2016 at 7:27pm UTC
i'm doing ownerdraw menus, but the menu item size isn't correct.
after some research i found that the WM_MEASUREITEM it's for change the menu item size:
1 2 3 4 5 6 7 8 9 10 11
case WM_MEASUREITEM:
{
MEASUREITEMSTRUCT *DrawMenuSize=(MEASUREITEMSTRUCT *)lParam;
if (DrawMenuSize->CtlID==ODT_MENU)
{
DrawMenuSize->itemWidth=50;
DrawMenuSize->itemHeight=20;
return TRUE;
}
}
break ;
but why the size isn't changed?
Oct 24, 2016 at 8:40am UTC
Oct 24, 2016 at 6:17pm UTC
i did a big mistake... it's 'CtlType'.
now i can resize it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
case WM_MEASUREITEM:
{
LPMEASUREITEMSTRUCT DrawMenuSize=(LPMEASUREITEMSTRUCT)lParam;
if (DrawMenuSize->CtlType==ODT_MENU)
{
Menu *mMenu=(Menu *)DrawMenuSize->itemData;
//DebugText(to_string(MenuItemSize.cx) + "\t" + to_string(MenuItemSize.cy));
if (MenuItemSize.cx>0 && MenuItemSize.cy>0)
{
DrawMenuSize->itemWidth=MenuItemSize.cx;
DrawMenuSize->itemHeight=MenuItemSize.cy;
}
else
{
DrawMenuSize->itemWidth=50;
DrawMenuSize->itemHeight=20;
}
return TRUE;
}
}
break ;
case WM_DRAWITEM:
{
DRAWITEMSTRUCT *DrawMenuStructure=(DRAWITEMSTRUCT *)lParam;
if (DrawMenuStructure->CtlType==ODT_MENU)
{
MENUITEMINFO menuInfo;
menuInfo.cbSize = sizeof (MENUITEMINFO);
menuInfo.fMask=MIIM_DATA;
GetMenuItemInfo((HMENU)DrawMenuStructure->hwndItem,DrawMenuStructure->itemID, FALSE, &menuInfo );
Menu *mMenu = (Menu *) menuInfo.dwItemData;
if (mMenu->MenuDrawed)
mMenu->MenuDrawed(DrawMenuStructure->hDC,DrawMenuStructure->rcItem,&MenuItemSize, DrawMenuStructure->itemState);
if ((DrawMenuStructure->rcItem.bottom!=MenuItemSize.cy) && (DrawMenuStructure->rcItem.right!=MenuItemSize.cx) )
{
DrawMenuBar(inst->hwnd);
mMenu->SetMenuDrawed(!mMenu->GetMenuDrawed());
mMenu->SetMenuDrawed(!mMenu->GetMenuDrawed());
}
if (mMenu->MenuDrawed)
mMenu->MenuDrawed(DrawMenuStructure->hDC,DrawMenuStructure->rcItem,&MenuItemSize, DrawMenuStructure->itemState);
}
}
break ;
but for be redrawed, i must move the mouse to it. can you advice more?
Topic archived. No new replies allowed.