WM_DRAWITEM- DRAWITEMSTRUCT: how can i detect the mouse enter and mouse leave on menu?

using the DRAWITEMSTRUCT on WM_DRAWITEM, for menus, how can i detect the mouse enter and mouse leave?
i did these code, but isn't working correctly:
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
//***************
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->itemAction, DrawMenuStructure->itemState);
                     }
                }
                break;
//***************
mnuSecondHello.MenuDrawed=[](HDC MenuHDC, RECT MenuRect,SIZE *MenuItemSize, UINT Action, UINT MenuState)
        {
            SetTextColor(MenuHDC, ChFont.rgbColors);
            HFONT hfDrawed=CreateFontIndirect(ChFont.lpLogFont);
            SelectFont(MenuHDC,hfDrawed);
            *MenuItemSize=GetStringSize(mnuSecondHello.Caption, MenuHDC);
            string strCaption = mnuSecondHello.Caption;
            SetBkMode(MenuHDC, TRANSPARENT);
            if(Action==ODA_SELECT)
            {
                DrawControlBackground(MenuHDC,"MENU",MENU_POPUPITEM,MPI_HOT,MenuRect);
            }
            DrawText(MenuHDC,&strCaption[0], -1,&MenuRect,DT_CENTER|DT_LEFT| DT_EXPANDTABS);
            DeleteFont(hfDrawed);
        };

i'm testing if the Action(itemAction) is ODA_SELECT(when mouse enter), but isn't working correctly, because when i move out, the menu item isn't redrawed to defauld way. can anyone correct me?
You could try to handle the WM_MOUSEMOVE message and check if the the mouse cursor is over the menu.
Topic archived. No new replies allowed.