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

ktranmsg.c File Reference

#include "precomp.h"

Go to the source code of this file.

Classes

struct  tagMYIMESTRUCT

Typedefs

typedef tagMYIMESTRUCT MYIMESTRUCT
typedef MYIMESTRUCTLPMYIMESTRUCT

Functions

UINT WINNLSTranslateMessageK (int iNumMsg, PTRANSMSG pTransMsg, LPINPUTCONTEXT lpIMC, LPCOMPOSITIONSTRING lpCompStr, BOOL bAnsiIMC)

Variables

MYIMESTRUCT myIME = { 0, 0, 0, sizeof(IMESTRUCT), sizeof(IMESTRUCT) + 256, 0}


Typedef Documentation

typedef MYIMESTRUCT* LPMYIMESTRUCT
 

Definition at line 29 of file ktranmsg.c.

typedef struct tagMYIMESTRUCT MYIMESTRUCT
 


Function Documentation

UINT WINNLSTranslateMessageK int  iNumMsg,
PTRANSMSG  pTransMsg,
LPINPUTCONTEXT  lpIMC,
LPCOMPOSITIONSTRING  lpCompStr,
BOOL  bAnsiIMC
 

Definition at line 128 of file ktranmsg.c.

References BOOL, BYTE, CHAR, FALSE, HIBYTE, hWnd, ImmGetDefaultIMEWnd(), IsWindowUnicode(), L, LOBYTE, NULL, TRUE, and UINT.

Referenced by WINNLSTranslateMessage().

00133 { 00134 HWND hDefIMEWnd; 00135 int i, j; 00136 static BYTE bp1stInterim = 0; 00137 static BYTE bp2ndInterim = 0; 00138 BOOL bAnsiWnd; 00139 HWND hWnd; 00140 WCHAR wchUni; 00141 CHAR chAnsi[2]; 00142 BYTE bchLow, bchHi, bCh; 00143 BOOL (WINAPI* fpPostMessage)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); 00144 LRESULT (WINAPI* fpSendMessage)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); 00145 00146 hWnd = (HWND)lpIMC->hWnd; 00147 00148 hDefIMEWnd = ImmGetDefaultIMEWnd(hWnd); 00149 00150 bAnsiWnd = !IsWindowUnicode(hWnd) ? TRUE : FALSE; 00151 if (bAnsiWnd) { 00152 fpPostMessage = PostMessageA; 00153 fpSendMessage = SendMessageA; 00154 } else { 00155 fpPostMessage = PostMessageW; 00156 fpSendMessage = SendMessageW; 00157 } 00158 00159 for (i = 0; i < iNumMsg; i++) { 00160 00161 switch (pTransMsg[i].message) { 00162 00163 case WM_IME_COMPOSITION : 00164 00165 if (pTransMsg[i].lParam & GCS_RESULTSTR) { 00166 00167 fpPostMessage(hWnd, WM_IME_REPORT, IR_STRINGSTART, 0L); 00168 00169 for (j = 0; j < (int)lpCompStr->dwResultStrLen; j++) { 00170 LPARAM lParam; 00171 bCh = 0; 00172 if (bAnsiIMC) { 00173 bCh = *((LPSTR)lpCompStr + lpCompStr->dwResultStrOffset + j); 00174 if (bAnsiWnd) { 00175 if (IsDBCSLeadByte(bCh)) { 00176 lParam = (bCh >= 0xB0 && bCh <= 0xC8)? 0xFFF10001L: 0xFFF20001L; 00177 PostMessageA(hWnd, WM_CHAR, bCh, lParam); 00178 bCh = *((LPSTR)lpCompStr + lpCompStr->dwResultStrOffset + ++j); 00179 } else 00180 lParam = 1L; 00181 PostMessageA(hWnd, WM_CHAR, bCh, lParam); 00182 } else { 00183 chAnsi[0] = bCh; 00184 chAnsi[1] = *((LPSTR)lpCompStr + lpCompStr->dwResultStrOffset + ++j); 00185 00186 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, chAnsi, 2, &wchUni, 1); 00187 00188 PostMessageW(hWnd, WM_CHAR, wchUni, lParam); 00189 } 00190 } else { // !bAnsiIMC 00191 bCh = *((LPSTR)lpCompStr + lpCompStr->dwResultStrOffset + j * sizeof(WCHAR)); 00192 wchUni = bCh | ( *((LPSTR)lpCompStr + lpCompStr->dwResultStrOffset + 00193 (j * sizeof(WCHAR) + 1)) << 8); 00194 00195 if (bAnsiWnd) { 00196 WideCharToMultiByte(CP_ACP, 0, &wchUni, 1, chAnsi, 2, NULL, NULL); 00197 00198 bchLow = chAnsi[0]; 00199 bchHi = chAnsi[0]; //(BYTE)chAnsi; 00200 00201 if (IsDBCSLeadByte(bchLow)) { 00202 lParam = (bchLow >= 0xB0 && bchLow <= 0xC8) ? 0xFFF10001L: 0xFFF20001L; 00203 PostMessageA(hWnd, WM_CHAR, bchLow, lParam); 00204 bchHi = chAnsi[1]; 00205 } else 00206 lParam = 1L; 00207 00208 PostMessageA(hWnd, WM_CHAR, bchHi, lParam); 00209 } else { 00210 PostMessageW(hWnd, WM_CHAR, wchUni, lParam); 00211 } 00212 } 00213 } 00214 00215 fpPostMessage(hWnd, WM_IME_REPORT, IR_STRINGEND, 0L); 00216 00217 } else { // !(pTransMsg[i].lParam & GCS_RESULTSTR) 00218 00219 if (pTransMsg[i].wParam) { 00220 00221 fpPostMessage(hWnd, WM_IME_REPORT, IR_STRINGSTART, 0L); 00222 00223 bp1stInterim = HIBYTE(LOWORD(pTransMsg[i].wParam)); 00224 bp2ndInterim = LOBYTE(LOWORD(pTransMsg[i].wParam)); 00225 00226 if (bAnsiIMC) { 00227 if (bAnsiWnd) { 00228 PostMessageA(hWnd, WM_INTERIM, bp1stInterim, 0x00F00001L); 00229 PostMessageA(hWnd, WM_INTERIM, bp2ndInterim, 0x00F00001L); 00230 PostMessageA(hWnd, WM_IME_REPORT, IR_STRINGEND, 0L); 00231 } else { 00232 chAnsi[0] = bp1stInterim; 00233 chAnsi[1] = bp2ndInterim; 00234 00235 if (MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, chAnsi, 2, &wchUni, 1)) 00236 PostMessageW(hWnd, WM_INTERIM, wchUni, 0x00F00001L); 00237 PostMessageW(hWnd, WM_IME_REPORT, IR_STRINGEND, 0L); 00238 } 00239 00240 } else { 00241 if (bAnsiWnd) { 00242 wchUni = (bp1stInterim << 8) | bp2ndInterim; //(WORD)lpdwTransKey[i*3 + 1]; 00243 WideCharToMultiByte(CP_ACP, 0, &wchUni, 1, chAnsi, 2, NULL, NULL); 00244 00245 bchLow = chAnsi[0]; 00246 bchHi = chAnsi[1]; 00247 00248 PostMessageA(hWnd, WM_INTERIM, bchLow, 0x00F00001L); 00249 PostMessageA(hWnd, WM_INTERIM, bchHi, 0x00F00001L); 00250 PostMessageA(hWnd, WM_IME_REPORT, IR_STRINGEND, 0L); 00251 } else { 00252 PostMessageW(hWnd, WM_INTERIM, pTransMsg[i].wParam, 0x00F00001L); 00253 PostMessageW(hWnd, WM_IME_REPORT, IR_STRINGEND, 0L); 00254 } 00255 } 00256 fpSendMessage(hDefIMEWnd, WM_IME_ENDCOMPOSITION, 0, 0L); 00257 00258 } else { // !pTransMsg[i].wParam 00259 00260 fpPostMessage(hWnd, WM_IME_REPORT, IR_STRINGSTART, 0L); 00261 00262 if (bAnsiIMC) { 00263 if (bAnsiWnd) { 00264 PostMessageA(hWnd, WM_CHAR, bp1stInterim, 0xFFF10001L); 00265 PostMessageA(hWnd, WM_CHAR, bp2ndInterim, 0xFFF10001L); 00266 PostMessageA(hWnd, WM_IME_REPORT, IR_STRINGEND, 0L); 00267 PostMessageA(hWnd, WM_KEYDOWN, VK_BACK, 0x000E0001L); 00268 } else { 00269 chAnsi[0] = bp1stInterim; 00270 chAnsi[1] = bp2ndInterim; 00271 00272 if (MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, chAnsi, 2, &wchUni, 1)) 00273 PostMessageW(hWnd, WM_CHAR, wchUni, 0xFFF10001L); 00274 00275 PostMessageW(hWnd, WM_IME_REPORT, IR_STRINGEND, 0L); 00276 PostMessageW(hWnd, WM_KEYDOWN, VK_BACK, 0x000E0001L); 00277 } 00278 } else { // !bAnsiIMC 00279 if (bAnsiWnd) { 00280 wchUni = (bp1stInterim << 8 ) | bp2ndInterim; 00281 00282 WideCharToMultiByte(CP_ACP, 0, &wchUni, 1, chAnsi, 2, NULL, NULL); 00283 00284 bchLow = chAnsi[0]; 00285 bchHi = chAnsi[1]; 00286 00287 PostMessageA(hWnd, WM_CHAR, bchLow, 0xFFF10001L); 00288 PostMessageA(hWnd, WM_CHAR, bchHi, 0xFFF10001L); 00289 PostMessageA(hWnd, WM_IME_REPORT, IR_STRINGEND, 0L); 00290 PostMessageA(hWnd, WM_KEYDOWN, VK_BACK, 0x000E0001L); 00291 } else { 00292 wchUni = bp1stInterim | (bp2ndInterim << 8); 00293 00294 PostMessageW(hWnd, WM_CHAR, wchUni, 0xFFF10001L); 00295 PostMessageW(hWnd, WM_IME_REPORT, IR_STRINGEND, 0L); 00296 PostMessageW(hWnd, WM_KEYDOWN, VK_BACK, 0x000E0001L); 00297 } 00298 } 00299 } 00300 } 00301 break; 00302 00303 case WM_IME_STARTCOMPOSITION : 00304 case WM_IME_ENDCOMPOSITION : 00305 break; 00306 00307 case WM_IME_KEYDOWN: 00308 fpPostMessage(hWnd, WM_KEYDOWN, LOWORD(pTransMsg[i].wParam), 00309 pTransMsg[i].lParam); 00310 break; 00311 00312 case WM_IME_KEYUP: 00313 fpPostMessage(hWnd, WM_KEYUP, LOWORD(pTransMsg[i].wParam), 00314 pTransMsg[i].lParam); 00315 break; 00316 00317 default : 00318 fpSendMessage(hDefIMEWnd, pTransMsg[i].message, 00319 pTransMsg[i].wParam, pTransMsg[i].lParam); 00320 break; 00321 } 00322 } 00323 00324 return 0; // indicates all messages are post/sent within this function. 00325 }


Variable Documentation

MYIMESTRUCT myIME = { 0, 0, 0, sizeof(IMESTRUCT), sizeof(IMESTRUCT) + 256, 0}
 

Definition at line 31 of file ktranmsg.c.


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