Open henrypp opened 1 month ago
#define WM_UAHDRAWMENU 0x0091 // lParam is UAHMENU #define WM_UAHDRAWMENUITEM 0x0092 // lParam is UAHDRAWMENUITEM // hmenu is the main window menu; hdc is the context to draw in typedef struct _UAHMENU { HMENU hmenu; HDC hdc; ULONG dwFlags; // no idea what these mean, in my testing it's either 0x00000a00 or sometimes 0x00000a10 } UAHMENU, *LPUAHMENU; // the position index of the item in the menu, which is duplicated in // the UAHMENUITEM's iPosition as well typedef struct _UAHDRAWMENUITEM { DRAWITEMSTRUCT dis; UAHMENU um; UAHMENUITEM umi; } UAHDRAWMENUITEM, *LPUAHDRAWMENUITEM; case WM_UAHDRAWMENU: { MENUBARINFO mbi = {0}; LPUAHMENU menu_item; RECT rect; menu_item = (LPUAHMENU)lparam; mbi.cbSize = sizeof (mbi); // get the menubar rect if (!GetMenuBarInfo (hwnd, OBJID_MENU, 0, &mbi)) break; if (!GetWindowRect (hwnd, &rect)) break; // the rcBar is offset by the window rect OffsetRect (&mbi.rcBar, -rect.left, -rect.top); mbi.rcBar.top -= 1; FillRect (menu_item->hdc, &mbi.rcBar, <dark color brush>); return TRUE; } case WM_UAHDRAWMENUITEM: { LPUAHDRAWMENUITEM menu_item; MENUITEMINFO mii = {0}; DTTOPTS dtto = {0}; WCHAR buffer[128] = {0}; HTHEME htheme; ULONG flags = DT_CENTER | DT_SINGLELINE | DT_VCENTER; INT state_id = MPI_NORMAL; menu_item = (LPUAHDRAWMENUITEM)lparam; mii.cbSize = sizeof (mii); mii.fMask = MIIM_STRING; mii.dwTypeData = buffer; mii.cch = RTL_NUMBER_OF (buffer); if (!GetMenuItemInfoW (menu_item->um.hmenu, menu_item->umi.iPosition, TRUE, &mii)) break; if ((menu_item->dis.itemState & ODS_DEFAULT) || (menu_item->dis.itemState & ODS_INACTIVE)) state_id = MBI_NORMAL; // normal display if ((menu_item->dis.itemState & ODS_SELECTED) || (menu_item->dis.itemState & ODS_HOTLIGHT)) state_id = MBI_HOT; // hot tracking if ((menu_item->dis.itemState & ODS_GRAYED) || (menu_item->dis.itemState & ODS_DISABLED)) state_id = MBI_DISABLED; if (menu_item->dis.itemState & ODS_NOACCEL) flags |= DT_HIDEPREFIX; htheme = OpenThemeData (hwnd, VSCLASS_MENU); if (!htheme) break; FillRect (menu_item->um.hdc, &menu_item->dis.rcItem, <dark color brush>); DrawThemeBackground (htheme, menu_item->um.hdc, MENU_POPUPITEM, state_id, &menu_item->dis.rcItem, NULL); dtto.dwFlags = DTT_TEXTCOLOR; dtto.crText = RGB (255, 255, 255); DrawThemeTextEx (htheme, menu_item->um.hdc, MENU_BARITEM, state_id, buffer, (UINT)wcslen (buffer), flags, &menu_item->dis.rcItem, &dtto); (htheme, menu_item->um.hdc, &sr, &menu_item->dis.rcItem, MENU_BARITEM, state_id, flags, WND_TEXT_CLR); CloseThemeData (htheme); return TRUE; }
ps: taked from win32-custom-menubar-aero-theme
now it looks like this:
any update?
Okay, now it looks fine, but listview header is not dark themed, how it can be done.
ps: taked from win32-custom-menubar-aero-theme