SHORT _GetKeyState( int vk) { UINT wKeyState; PTHREADINFO pti; if ((UINT)vk >= CVKKEYSTATE) { RIPERR1(ERROR_INVALID_PARAMETER, RIP_WARNING, "Invalid parameter \"vk\" (%ld) to _GetKeyState", vk); return 0; } pti = PtiCurrentShared(); #ifdef LATER // // note - anything that accesses the pq structure is a bad idea since it // can be changed between any two instructions. // #endif wKeyState = 0; /* * Set the toggle bit. */ if (TestKeyStateToggle(pti->pq, vk)) wKeyState = 0x0001; /* * Set the keyup/down bit. */ if (TestKeyStateDown(pti->pq, vk)) { /* * Used to be wKeyState|= 0x8000.Fix for bug 28820; Ctrl-Enter * accelerator doesn't work on Nestscape Navigator Mail 2.0 */ wKeyState |= 0xff80; // This is what 3.1 returned!!!! } return (SHORT)wKeyState; }
DWORD CheckImeHotKey( PQ pq, // input queue UINT uVKey, // virtual key LPARAM lParam // lparam of WM_KEYxxx message ) { static UINT uVKeySaved = 0; PIMEHOTKEYOBJ ph; UINT uModifiers = 0; BOOL fKeyUp; // // early return for key up message // fKeyUp = ( lParam & 0x80000000 ) ? TRUE : FALSE; if ( fKeyUp ) { // // if the uVKey is not same as the vkey // we previously saved, there is no chance // that this is a hotkey. // if ( uVKeySaved != uVKey ) { uVKeySaved = 0; return IME_INVALID_HOTKEY; } uVKeySaved = 0; // // If it's same, we still need to check // the hotkey list because there is a // chance that the hotkey list is modified // between the key make and break. // } // // Current specification doesn't allow us to use a complex // hotkey such as LSHIFT+RMENU+SPACE // if ( uVKey != VK_SHIFT ) { uModifiers |= TestKeyStateDown( pq, VK_LSHIFT ) ? (MOD_SHIFT | MOD_LEFT) : 0; uModifiers |= TestKeyStateDown( pq, VK_RSHIFT ) ? (MOD_SHIFT | MOD_RIGHT) : 0; } if ( uVKey != VK_CONTROL ) { uModifiers |= TestKeyStateDown( pq, VK_LCONTROL ) ? (MOD_CONTROL | MOD_LEFT) : 0; uModifiers |= TestKeyStateDown( pq, VK_RCONTROL ) ? (MOD_CONTROL | MOD_RIGHT) : 0; } if ( uVKey != VK_MENU ) { uModifiers |= TestKeyStateDown( pq, VK_LMENU ) ? (MOD_ALT | MOD_LEFT) : 0; uModifiers |= TestKeyStateDown( pq, VK_RMENU ) ? (MOD_ALT | MOD_RIGHT) : 0; } ph = FindImeHotKeyByKey( gpImeHotKeyListHeader, uModifiers & MOD_MODIFY_KEYS, uModifiers & MOD_BOTH_SIDES, uVKey ); if ( ph != NULL ) { if ( fKeyUp ) { if ( ph->hk.uModifiers & MOD_ON_KEYUP ) { return ph->hk.dwHotKeyID; } } else { if ( ph->hk.uModifiers & MOD_ON_KEYUP ) { // // save vkey for next keyup message time // // when ALT+Z is a hotkey, we don't want // to handle #2 as the hotkey sequence. // 1) ALT make -> 'Z' make -> 'Z' break // 2) 'Z' make -> ALT make -> 'Z' break // uVKeySaved = uVKey; } else { return ph->hk.dwHotKeyID; } } } return IME_INVALID_HOTKEY; }