From f5d2ea6ca4af4f845118df8e2ac7919d7ee86e0d Mon Sep 17 00:00:00 2001 From: Rein Klazes Date: Wed, 6 Jul 2005 19:03:18 +0000 Subject: [PATCH] - when sending the WM_DRAWITEM message in case of a menu item with hbmpItem = HBMMENU_CALLBACK, move the drawing origin to the top left of the item rectangle - at the same time also make sure that the itemState field of the DRAWITEMSTRUCT is properly initialized - do the drawing of the check mark before sending the WM_DRAWITEM message, some application likes to "overdraw" the checkmark. --- dlls/user/menu.c | 67 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/dlls/user/menu.c b/dlls/user/menu.c index 119bc7a5148..b2ddd5b829d 100644 --- a/dlls/user/menu.c +++ b/dlls/user/menu.c @@ -1318,39 +1318,16 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc, if (!(lpitem->fType & MF_OWNERDRAW)) { + RECT rc; + rc = rect; /* New style MIIM_BITMAP */ if (lpitem->hbmpItem) { POPUPMENU *menu = MENU_GetMenu(hmenu); - HBITMAP hbm = lpitem->hbmpItem; - - if (hbm == HBMMENU_CALLBACK) - { - DRAWITEMSTRUCT drawItem; - drawItem.CtlType = ODT_MENU; - drawItem.CtlID = 0; - drawItem.itemID = lpitem->wID; - drawItem.itemAction = odaction; - drawItem.itemState |= (lpitem->fState & MF_CHECKED)?ODS_CHECKED:0; - drawItem.itemState |= (lpitem->fState & MF_DEFAULT)?ODS_DEFAULT:0; - drawItem.itemState |= (lpitem->fState & MF_DISABLED)?ODS_DISABLED:0; - drawItem.itemState |= (lpitem->fState & MF_GRAYED)?ODS_GRAYED|ODS_DISABLED:0; - drawItem.itemState |= (lpitem->fState & MF_HILITE)?ODS_SELECTED:0; - drawItem.hwndItem = (HWND)hmenu; - drawItem.hDC = hdc; - drawItem.rcItem = lpitem->rect; - drawItem.itemData = lpitem->dwItemData; - - if (!(lpitem->fState & MF_CHECKED)) - SendMessageW( hwndOwner, WM_DRAWITEM, 0, (LPARAM)&drawItem); - - } else { - MENU_DrawBitmapItem(hdc, lpitem, &rect, FALSE, TRUE); - } if (menu->dwStyle & MNS_CHECKORBMP) - rect.left += menu->maxBmpSize.cx - check_bitmap_width; + rc.left += menu->maxBmpSize.cx - check_bitmap_width; else - rect.left += menu->maxBmpSize.cx; + rc.left += menu->maxBmpSize.cx; } /* Draw the check mark * @@ -1362,7 +1339,7 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc, { HDC hdcMem = CreateCompatibleDC( hdc ); SelectObject( hdcMem, bm ); - BitBlt( hdc, rect.left, (y - check_bitmap_height) / 2, + BitBlt( hdc, rc.left, (y - check_bitmap_height) / 2, check_bitmap_width, check_bitmap_height, hdcMem, 0, 0, SRCCOPY ); DeleteDC( hdcMem ); @@ -1377,11 +1354,43 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc, DrawFrameControl( hdcMem, &r, DFC_MENU, (lpitem->fType & MFT_RADIOCHECK) ? DFCS_MENUBULLET : DFCS_MENUCHECK ); - BitBlt( hdc, rect.left, (y - r.bottom) / 2, r.right, r.bottom, + BitBlt( hdc, rc.left, (y - r.bottom) / 2, r.right, r.bottom, hdcMem, 0, 0, SRCCOPY ); DeleteDC( hdcMem ); DeleteObject( bm ); } + /* New style MIIM_BITMAP */ + if (lpitem->hbmpItem) + { + HBITMAP hbm = lpitem->hbmpItem; + + if (hbm == HBMMENU_CALLBACK) + { + DRAWITEMSTRUCT drawItem; + POINT origorg; + drawItem.CtlType = ODT_MENU; + drawItem.CtlID = 0; + drawItem.itemID = lpitem->wID; + drawItem.itemAction = odaction; + drawItem.itemState = (lpitem->fState & MF_CHECKED)?ODS_CHECKED:0; + drawItem.itemState |= (lpitem->fState & MF_DEFAULT)?ODS_DEFAULT:0; + drawItem.itemState |= (lpitem->fState & MF_DISABLED)?ODS_DISABLED:0; + drawItem.itemState |= (lpitem->fState & MF_GRAYED)?ODS_GRAYED|ODS_DISABLED:0; + drawItem.itemState |= (lpitem->fState & MF_HILITE)?ODS_SELECTED:0; + drawItem.hwndItem = (HWND)hmenu; + drawItem.hDC = hdc; + drawItem.rcItem = lpitem->rect; + drawItem.itemData = lpitem->dwItemData; + /* some applications make this assumption on the DC's origin */ + SetViewportOrgEx( hdc, lpitem->rect.left, lpitem->rect.top, &origorg); + OffsetRect( &drawItem.rcItem, - lpitem->rect.left, - lpitem->rect.top); + SendMessageW( hwndOwner, WM_DRAWITEM, 0, (LPARAM)&drawItem); + SetViewportOrgEx( hdc, origorg.x, origorg.y, NULL); + + } else { + MENU_DrawBitmapItem(hdc, lpitem, &rect, FALSE, TRUE); + } + } } /* Draw the popup-menu arrow */ -- 2.11.4.GIT