Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

keyconv.c File Reference

#include "precomp.h"

Go to the source code of this file.

Functions

BOOL xxxTranslateMessage (LPMSG pmsg, UINT uiTMFlags)


Function Documentation

BOOL xxxTranslateMessage LPMSG  pmsg,
UINT  uiTMFlags
 

Definition at line 28 of file keyconv.c.

References _PostMessage(), tagQ::afKeyState, BOOL, DWORD, FALSE, HW, NULL, tagMENUSTATE::pGlobalPopupMenu, tagTHREADINFO::pMenuState, tagTHREADINFO::pq, PtiCurrent, tagPOPUPMENU::spwndPopupMenu, TRUE, UINT, ValidateHwnd, and xxxInternalToUnicode().

Referenced by NtUserTranslateMessage(), xxxHandleMenuMessages(), xxxHelpLoop(), xxxMNLoop(), xxxMoveSize(), xxxOldNextWindow(), and xxxSBTrackLoop().

00031 { 00032 PTHREADINFO pti; 00033 UINT wMsgType; 00034 int cChar; 00035 BOOL fSysKey = FALSE; 00036 DWORD dwKeyFlags; 00037 LPARAM lParam; 00038 UINT uVirKey; 00039 PWND pwnd; 00040 WCHAR awch[16]; 00041 WCHAR *pwch; 00042 00043 switch (pmsg->message) { 00044 00045 default: 00046 return FALSE; 00047 00048 case WM_SYSKEYDOWN: 00049 /* 00050 * HACK carried over from Win3 code: system messages 00051 * only get posted during KEYDOWN processing - so 00052 * set fSysKey only for WM_SYSKEYDOWN. 00053 */ 00054 fSysKey = TRUE; 00055 /* 00056 * Fall thru... 00057 */ 00058 00059 case WM_SYSKEYUP: 00060 case WM_KEYDOWN: 00061 case WM_KEYUP: 00062 pti = PtiCurrent(); 00063 00064 if ((pti->pMenuState != NULL) && 00065 (HW(pti->pMenuState->pGlobalPopupMenu->spwndPopupMenu) == 00066 pmsg->hwnd)) { 00067 uiTMFlags |= TM_INMENUMODE; 00068 } else { 00069 uiTMFlags &= ~TM_INMENUMODE; 00070 } 00071 00072 /* 00073 * Don't change the contents of the passed in structure. 00074 */ 00075 lParam = pmsg->lParam; 00076 00077 /* 00078 * For backward compatibility, mask the virtual key value. 00079 */ 00080 uVirKey = LOWORD(pmsg->wParam); 00081 00082 cChar = xxxInternalToUnicode(uVirKey, // virtual key code 00083 HIWORD(lParam), // scan code, make/break bit 00084 pti->pq->afKeyState, 00085 awch, sizeof(awch)/sizeof(awch[0]), 00086 uiTMFlags, &dwKeyFlags, NULL); 00087 lParam |= (dwKeyFlags & ALTNUMPAD_BIT); 00088 00089 /* 00090 * LATER 12/7/90 - GregoryW 00091 * Note: Win3.x TranslateMessage returns TRUE if ToAscii is called. 00092 * Proper behavior is to return TRUE if any translation is 00093 * performed by ToAscii. If we have to remain compatible 00094 * (even though apps clearly don't currently care about the 00095 * return value) then the following return should be changed 00096 * to TRUE. If we want the new 32-bit apps to have a meaningful 00097 * return value we should leave this as FALSE. 00098 * 00099 * If console is calling us with the TM_POSTCHARBREAKS flag then we 00100 * return FALSE if no char was actually posted 00101 * 00102 * !!! LATER get console to change so it does not need private API 00103 * TranslateMessageEx 00104 */ 00105 00106 if (!cChar) { 00107 if (uiTMFlags & TM_POSTCHARBREAKS) 00108 return FALSE; 00109 else 00110 return TRUE; 00111 } 00112 00113 /* 00114 * Some translation performed. Figure out what type of 00115 * message to post. 00116 * 00117 */ 00118 if (cChar > 0) 00119 wMsgType = (fSysKey) ? (UINT)WM_SYSCHAR : (UINT)WM_CHAR; 00120 else { 00121 wMsgType = (fSysKey) ? (UINT)WM_SYSDEADCHAR : (UINT)WM_DEADCHAR; 00122 cChar = -cChar; // want positive value 00123 } 00124 00125 if (dwKeyFlags & KBDBREAK) { 00126 lParam |= 0x80000000; 00127 } else { 00128 lParam &= ~0x80000000; 00129 } 00130 00131 /* 00132 * Since xxxInternalToUnicode can leave the crit sect, we need to 00133 * validate the message hwnd here. 00134 */ 00135 pwnd = ValidateHwnd(pmsg->hwnd); 00136 if (!pwnd) { 00137 return FALSE; 00138 } 00139 00140 for (pwch = awch; cChar > 0; cChar--) { 00141 00142 /* 00143 * If this is a multi-character posting, all but the last one 00144 * should be marked as fake keystrokes for Console/VDM. 00145 */ 00146 _PostMessage(pwnd, wMsgType, (WPARAM)*pwch, 00147 lParam | (cChar > 1 ? FAKE_KEYSTROKE : 0)); 00148 00149 *pwch = 0; // zero out old character (why?) 00150 pwch += 1; 00151 } 00152 00153 return TRUE; 00154 } 00155 }


Generated on Sat May 15 19:44:28 2004 for test by doxygen 1.3.7