diff --git a/reactos/win32ss/user/ntuser/keyboard.c b/reactos/win32ss/user/ntuser/keyboard.c index 8bb6b8b705c..160ac756ba5 100644 --- a/reactos/win32ss/user/ntuser/keyboard.c +++ b/reactos/win32ss/user/ntuser/keyboard.c @@ -845,6 +845,7 @@ ProcessKeyEvent(WORD wVk, WORD wScanCode, DWORD dwFlags, BOOL bInjected, DWORD d /* If we have a focus queue, post a keyboard message */ pFocusQueue = IntGetFocusMessageQueue(); + TRACE("ProcessKeyEvent Q 0x%p Focus pWnd 0x%p\n",pFocusQueue, pFocusQueue ? pFocusQueue->spwndFocus : 0); if (bIsDown && wVk == VK_SNAPSHOT) { if (pFocusQueue && @@ -1062,7 +1063,6 @@ IntTranslateKbdMessage(LPMSG lpMsg, WCHAR wch[3] = { 0 }; MSG NewMsg = { 0 }; PKBDTABLES pKbdTbl; - PWND pWnd; LARGE_INTEGER LargeTickCount; BOOL bResult = FALSE; @@ -1077,14 +1077,7 @@ IntTranslateKbdMessage(LPMSG lpMsg, return FALSE; } - pWnd = UserGetWindowObject(lpMsg->hwnd); - if (!pWnd) // Must have a window! - { - ERR("No Window for Translate.\n"); - return FALSE; - } - - pti = pWnd->head.pti; + pti = PsGetCurrentThreadWin32Thread(); if (!pti->KeyboardLayout) { diff --git a/reactos/win32ss/user/ntuser/message.c b/reactos/win32ss/user/ntuser/message.c index d493751b779..416fd6439ca 100644 --- a/reactos/win32ss/user/ntuser/message.c +++ b/reactos/win32ss/user/ntuser/message.c @@ -2116,12 +2116,12 @@ NtUserDispatchMessage(PMSG UnsafeMsgInfo) return Res; } - BOOL APIENTRY NtUserTranslateMessage(LPMSG lpMsg, UINT flags) { MSG SafeMsg; BOOL Ret; + PWND pWnd; _SEH2_TRY { @@ -2136,9 +2136,16 @@ NtUserTranslateMessage(LPMSG lpMsg, UINT flags) _SEH2_END; UserEnterExclusive(); - - Ret = IntTranslateKbdMessage(&SafeMsg, flags); - + pWnd = UserGetWindowObject(SafeMsg.hwnd); + if (pWnd) // Must have a window! + { + Ret = IntTranslateKbdMessage(&SafeMsg, flags); + } + else + { + ERR("No Window for Translate. hwnd 0x%p Msg %d\n",SafeMsg.hwnd,SafeMsg.message); + Ret = FALSE; + } UserLeave(); return Ret;