Author: jimtabor Date: Wed Jul 19 11:10:56 2006 New Revision: 23169
URL: http://svn.reactos.org/svn/reactos?rev=23169&view=rev Log: User32 Implement MenuTrackKbdMenuBar, it does work but, alt f works but hit alt again goes into a message loop. So hit alt f than esc esc. If hit alt f than alt v or something else the popup menu stays displayed until the program has terminated.
Modified: trunk/reactos/dll/win32/user32/include/menu.h trunk/reactos/dll/win32/user32/windows/defwnd.c trunk/reactos/dll/win32/user32/windows/menu.c
Modified: trunk/reactos/dll/win32/user32/include/menu.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/me... ============================================================================== --- trunk/reactos/dll/win32/user32/include/menu.h (original) +++ trunk/reactos/dll/win32/user32/include/menu.h Wed Jul 19 11:10:56 2006 @@ -17,6 +17,6 @@ VOID MenuTrackMouseMenuBar(HWND hWnd, ULONG Ht, POINT Pt); VOID -MenuTrackKbdMenuBar(HWND hWnd, ULONG wParam, ULONG Key); +MenuTrackKbdMenuBar(HWND hWnd, UINT wParam, WCHAR wChar);
#endif /* __LIB_USER32_INCLUDE_MENU_H */
Modified: trunk/reactos/dll/win32/user32/windows/defwnd.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/de... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/defwnd.c (original) +++ trunk/reactos/dll/win32/user32/windows/defwnd.c Wed Jul 19 11:10:56 2006 @@ -766,9 +766,10 @@
LRESULT -DefWndHandleSysCommand(HWND hWnd, WPARAM wParam, POINT Pt) +DefWndHandleSysCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { WINDOWPLACEMENT wp; + POINT Pt;
switch (wParam & 0xfff0) { @@ -804,16 +805,24 @@ SendMessageA(hWnd, WM_CLOSE, 0, 0); break; case SC_MOUSEMENU: - MenuTrackMouseMenuBar(hWnd, wParam & 0x000f, Pt); + { + Pt.x = (short)LOWORD(lParam); + Pt.y = (short)HIWORD(lParam); + MenuTrackMouseMenuBar(hWnd, wParam & 0x000f, Pt); + } break; case SC_KEYMENU: - MenuTrackKbdMenuBar(hWnd, wParam, Pt.x); + MenuTrackKbdMenuBar(hWnd, wParam, (WCHAR)lParam); break; case SC_VSCROLL: case SC_HSCROLL: - DefWndTrackScrollBar(hWnd, wParam, Pt); + { + Pt.x = (short)LOWORD(lParam); + Pt.y = (short)HIWORD(lParam); + DefWndTrackScrollBar(hWnd, wParam, Pt); + } break; - + default: /* FIXME: Implement */ UNIMPLEMENTED; @@ -1305,13 +1314,7 @@ }
case WM_SYSCOMMAND: - { - POINT Pt; - Pt.x = GET_X_LPARAM(lParam); - Pt.y = GET_Y_LPARAM(lParam); - return (DefWndHandleSysCommand(hWnd, wParam, Pt)); - } - + return (DefWndHandleSysCommand(hWnd, wParam, lParam));
case WM_KEYDOWN: if(wParam == VK_F10) iF10Key = VK_F10;
Modified: trunk/reactos/dll/win32/user32/windows/menu.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/me... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/menu.c (original) +++ trunk/reactos/dll/win32/user32/windows/menu.c Wed Jul 19 11:10:56 2006 @@ -3320,9 +3320,13 @@ fRemove = TRUE; /* Keyboard messages are always removed */ switch(Msg.message) { + case WM_SYSKEYDOWN: case WM_KEYDOWN: switch(Msg.wParam) { + case VK_MENU: + fEndMenu = TRUE; + break; case VK_HOME: case VK_END: if (MenuGetRosMenuInfo(&MenuInfo, Mt.CurrentMenu)) @@ -3408,20 +3412,6 @@ break; } break; /* WM_KEYDOWN */ - - case WM_SYSKEYDOWN: - switch (Msg.wParam) - { - DbgPrint("Menu.c WM_SYSKEYDOWN wPram %d\n",Msg.wParam); - case VK_MENU: - fEndMenu = TRUE; - break; - case VK_LMENU: - fEndMenu = TRUE; - break; - } - break; /* WM_SYSKEYDOWN */ - case WM_CHAR: case WM_SYSCHAR: { @@ -3566,8 +3556,73 @@
VOID -MenuTrackKbdMenuBar(HWND hWnd, ULONG wParam, ULONG Key) -{ +MenuTrackKbdMenuBar(HWND hWnd, UINT wParam, WCHAR wChar) +{ + UINT uItem = NO_SELECTED_ITEM; + HMENU hTrackMenu; + ROSMENUINFO MenuInfo; + UINT wFlags = TPM_ENTERIDLEEX | TPM_LEFTALIGN | TPM_LEFTBUTTON; + + DPRINT("hwnd %p wParam 0x%04x wChar 0x%04x\n", hWnd, wParam, wChar); + + /* find window that has a menu */ + + while (!((GetWindowLongW( hWnd, GWL_STYLE ) & + (WS_CHILD | WS_POPUP)) != WS_CHILD)) + if (!(hWnd = GetAncestor( hWnd, GA_PARENT ))) return; + + /* check if we have to track a system menu */ + + hTrackMenu = GetMenu( hWnd ); + if (!hTrackMenu || IsIconic(hWnd) || wChar == ' ' ) + { + if (!(GetWindowLongW( hWnd, GWL_STYLE ) & WS_SYSMENU)) return; + hTrackMenu = NtUserGetSystemMenu(hWnd, FALSE); + uItem = 0; + wParam |= HTSYSMENU; /* prevent item lookup */ + } + + if (!IsMenu( hTrackMenu )) return; + + MenuInitTracking( hWnd, hTrackMenu, FALSE, wFlags ); + + if (! MenuGetRosMenuInfo(&MenuInfo, hTrackMenu)) + { + goto track_menu; + } + + if( wChar && wChar != ' ' ) + { + uItem = MenuFindItemByKey( hWnd, &MenuInfo, wChar, (wParam & HTSYSMENU) ); + if ( uItem >= (UINT)(-2) ) + { + if( uItem == (UINT)(-1) ) MessageBeep(0); + /* schedule end of menu tracking */ + wFlags |= TF_ENDMENU; + goto track_menu; + } + } + + MenuSelectItem( hWnd, &MenuInfo, uItem, TRUE, 0 ); + + if (wParam & HTSYSMENU) + { + /* prevent sysmenu activation for managed windows on Alt down/up */ +// if (GetPropA( hwnd, "__wine_x11_managed" )) + wFlags |= TF_ENDMENU; /* schedule end of menu tracking */ + } + else + { + if( uItem == NO_SELECTED_ITEM ) + MenuMoveSelection( hWnd, &MenuInfo, ITEM_NEXT ); + else + PostMessageW( hWnd, WM_KEYDOWN, VK_DOWN, 0L ); + } + +track_menu: + MenuTrackMenu( hTrackMenu, wFlags, 0, 0, hWnd, NULL ); + MenuExitTracking( hWnd ); + }