user32: Implement support for HBMENU_POPUP_* magic menu bitmaps and use them to decorate the system menu.

This commit is contained in:
Rein Klazes 2009-02-20 15:28:37 +01:00 committed by Alexandre Julliard
parent cb2637fa5d
commit 0c6e37bb04
1 changed files with 48 additions and 5 deletions

View File

@ -419,8 +419,24 @@ static HMENU MENU_CopySysPopup(void)
HMENU hMenu = LoadMenuW(user32_module, sysmenuW); HMENU hMenu = LoadMenuW(user32_module, sysmenuW);
if( hMenu ) { if( hMenu ) {
MENUINFO minfo;
MENUITEMINFOW miteminfo;
POPUPMENU* menu = MENU_GetMenu(hMenu); POPUPMENU* menu = MENU_GetMenu(hMenu);
menu->wFlags |= MF_SYSMENU | MF_POPUP; menu->wFlags |= MF_SYSMENU | MF_POPUP;
minfo.cbSize = sizeof( MENUINFO);
minfo.dwStyle = MNS_CHECKORBMP;
minfo.fMask = MIM_STYLE;
SetMenuInfo( hMenu, &minfo);
miteminfo.cbSize = sizeof( MENUITEMINFOW);
miteminfo.fMask = MIIM_BITMAP;
miteminfo.hbmpItem = HBMMENU_POPUP_CLOSE;
SetMenuItemInfoW( hMenu, SC_CLOSE, FALSE, &miteminfo);
miteminfo.hbmpItem = HBMMENU_POPUP_RESTORE;
SetMenuItemInfoW( hMenu, SC_RESTORE, FALSE, &miteminfo);
miteminfo.hbmpItem = HBMMENU_POPUP_MAXIMIZE;
SetMenuItemInfoW( hMenu, SC_MAXIMIZE, FALSE, &miteminfo);
miteminfo.hbmpItem = HBMMENU_POPUP_MINIMIZE;
SetMenuItemInfoW( hMenu, SC_MINIMIZE, FALSE, &miteminfo);
SetMenuDefaultItem(hMenu, SC_CLOSE, FALSE); SetMenuDefaultItem(hMenu, SC_CLOSE, FALSE);
} }
else else
@ -819,7 +835,8 @@ static void MENU_GetBitmapItemSize( MENUITEM *lpitem, SIZE *size,
case (INT_PTR)HBMMENU_POPUP_RESTORE: case (INT_PTR)HBMMENU_POPUP_RESTORE:
case (INT_PTR)HBMMENU_POPUP_MAXIMIZE: case (INT_PTR)HBMMENU_POPUP_MAXIMIZE:
case (INT_PTR)HBMMENU_POPUP_MINIMIZE: case (INT_PTR)HBMMENU_POPUP_MINIMIZE:
FIXME("Magic %p not implemented\n", bmp ); size->cx = GetSystemMetrics( SM_CYMENU ) - 4; /* FIXME: test */
size->cy = size->cx;
return; return;
} }
if (GetObjectW(bmp, sizeof(bm), &bm )) if (GetObjectW(bmp, sizeof(bm), &bm ))
@ -852,6 +869,7 @@ static void MENU_DrawBitmapItem( HDC hdc, MENUITEM *lpitem, const RECT *rect,
if (IS_MAGIC_BITMAP(hbmToDraw)) if (IS_MAGIC_BITMAP(hbmToDraw))
{ {
UINT flags = 0; UINT flags = 0;
WCHAR bmchr = 0;
RECT r; RECT r;
switch((INT_PTR)hbmToDraw) switch((INT_PTR)hbmToDraw)
@ -910,17 +928,42 @@ static void MENU_DrawBitmapItem( HDC hdc, MENUITEM *lpitem, const RECT *rect,
} }
break; break;
case (INT_PTR)HBMMENU_POPUP_CLOSE: case (INT_PTR)HBMMENU_POPUP_CLOSE:
bmchr = 0x72;
break;
case (INT_PTR)HBMMENU_POPUP_RESTORE: case (INT_PTR)HBMMENU_POPUP_RESTORE:
bmchr = 0x32;
break;
case (INT_PTR)HBMMENU_POPUP_MAXIMIZE: case (INT_PTR)HBMMENU_POPUP_MAXIMIZE:
bmchr = 0x31;
break;
case (INT_PTR)HBMMENU_POPUP_MINIMIZE: case (INT_PTR)HBMMENU_POPUP_MINIMIZE:
bmchr = 0x30;
break;
default: default:
FIXME("Magic %p not implemented\n", hbmToDraw); FIXME("Magic %p not implemented\n", hbmToDraw);
return; return;
} }
if (bmchr)
{
HFONT hfont, hfontsav;
LOGFONTW logfont = { 0, 0, 0, 0, FW_NORMAL,
0, 0, 0, SYMBOL_CHARSET, 0, 0, 0, 0,
{ 'M','a','r','l','e','t','t',0 } };
logfont.lfHeight = min( h, w) - 2 ;
TRACE(" height %d rect %s\n", logfont.lfHeight, wine_dbgstr_rect( rect));
hfont = CreateFontIndirectW( &logfont);
hfontsav = SelectObject(hdc, hfont);
TextOutW( hdc, rect->left, rect->top, &bmchr, 1);
SelectObject(hdc, hfontsav);
DeleteObject( hfont);
}
else
{
r = *rect; r = *rect;
InflateRect( &r, -1, -1 ); InflateRect( &r, -1, -1 );
if (lpitem->fState & MF_HILITE) flags |= DFCS_PUSHED; if (lpitem->fState & MF_HILITE) flags |= DFCS_PUSHED;
DrawFrameControl( hdc, &r, DFC_CAPTION, flags ); DrawFrameControl( hdc, &r, DFC_CAPTION, flags );
}
return; return;
} }