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

keyconv.c

Go to the documentation of this file.
00001 /****************************** Module Header ******************************\ 00002 * Module Name: keyconv.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * History: 00007 * 11-06-90 DavidPe Created. 00008 * 13-Feb-1991 mikeke Added Revalidation code (None) 00009 \***************************************************************************/ 00010 00011 #include "precomp.h" 00012 #pragma hdrstop 00013 00014 /***************************************************************************\ 00015 * _TranslateMessage (API) 00016 * 00017 * This routine translates virtual keystroke messages as follows: 00018 * WM_KEYDOWN/WM_KEYUP are translated into WM_CHAR and WM_DEADCHAR 00019 * WM_SYSKEYDOWN/WM_SYSKEYDOWN are translated into WM_SYSCHAR and 00020 * WM_SYSDEADCHAR. The WM_*CHAR messages are posted to the application 00021 * queue. 00022 * 00023 * History: 00024 * 11-06-90 DavidPe Created stub functionality. 00025 * 12-07-90 GregoryW Modified to call _ToAscii for translations. 00026 \***************************************************************************/ 00027 00028 BOOL xxxTranslateMessage( 00029 LPMSG pmsg, 00030 UINT uiTMFlags) 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:40:35 2004 for test by doxygen 1.3.7