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

consubs.c

Go to the documentation of this file.
00001 // Copyright (c) 1985 - 1999, Microsoft Corporation 00002 // 00003 // MODULE: ConSubs.c 00004 // 00005 // PURPOSE: Console IME control. 00006 // 00007 // PLATFORMS: Windows NT-FE 3.51 00008 // 00009 // FUNCTIONS: 00010 // 00011 // History: 00012 // 00013 // 27.Jul.1995 v-HirShi (Hirotoshi Shimizu) created 00014 // 10.Jul.1996 v-HirShi (Hirotoshi Shimizu) adupt FE edition 00015 // 00016 // COMMENTS: 00017 // 00018 00019 #include "precomp.h" 00020 #pragma hdrstop 00021 00022 INT 00023 Create( HWND hWnd ) 00024 { 00025 ghDefaultIMC = ImmGetContext(hWnd) ; 00026 00027 #ifdef DEBUG_MODE 00028 { 00029 // 00030 // Select fixed pitch system font and get its text metrics 00031 // 00032 00033 HDC hdc; 00034 TEXTMETRIC tm; 00035 WORD patern = 0xA4A4; 00036 SIZE size; 00037 HFONT hfntFixed; // fixed-pitch font 00038 HFONT hfntOld; // default font holder 00039 00040 hdc = GetDC( hWnd ); 00041 hfntFixed = GetStockObject( SYSTEM_FIXED_FONT ); 00042 hfntOld = SelectObject( hdc, hfntFixed ); 00043 GetTextMetrics( hdc, &tm ); 00044 00045 GetTextExtentPoint32( hdc, (LPWSTR)&patern, sizeof(WORD), (LPSIZE) &size ); 00046 cxMetrics = (UINT) size.cx / 2; 00047 cyMetrics = (UINT) size.cy; 00048 ReleaseDC( hWnd, hdc ); 00049 00050 xPos = 0 ; 00051 CaretWidth = GetSystemMetrics( SM_CXBORDER ); 00052 } 00053 #endif 00054 00055 return 0; 00056 00057 } 00058 00059 //********************************************************************** 00060 // 00061 // void ImeUIStartComposition() 00062 // 00063 // This handles WM_IME_STARTCOMPOSITION message. 00064 // 00065 //********************************************************************** 00066 00067 void ImeUIStartComposition( HWND hwnd ) 00068 { 00069 PCONSOLE_TABLE ConTbl; 00070 00071 ConTbl = SearchConsole(LastConsole); 00072 if (ConTbl == NULL) { 00073 DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); 00074 return; 00075 } 00076 00077 // 00078 // Set fInComposition variables. 00079 // 00080 ConTbl->fInComposition = TRUE; 00081 00082 #ifdef DEBUG_MODE 00083 { 00084 int i ; 00085 for (i = FIRSTCOL ; i < MAXCOL ; i++) { 00086 ConvertLine[i] = UNICODE_SPACE ; 00087 ConvertLineAtr[i] = 0 ; 00088 } 00089 } 00090 #endif 00091 #ifdef DEBUG_INFO 00092 xPos = FIRSTCOL; 00093 xPosLast = FIRSTCOL; 00094 HideCaret( hwnd ); 00095 DisplayConvInformation( hwnd ) ; 00096 ResetCaret( hwnd ); 00097 #endif 00098 } 00099 00100 //********************************************************************** 00101 // 00102 // void ImeUIEndComposition 00103 // 00104 // This handles WM_IME_ENDCOMPOSITION message. 00105 // 00106 //********************************************************************** 00107 00108 void ImeUIEndComposition( HWND hwnd ) 00109 { 00110 PCONSOLE_TABLE ConTbl; 00111 00112 ConTbl = SearchConsole(LastConsole); 00113 if (ConTbl == NULL) { 00114 DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); 00115 return; 00116 } 00117 00118 // 00119 // Reset fInComposition variables. 00120 // 00121 ConTbl->fInComposition = FALSE; 00122 00123 if (ConTbl->lpCompStrMem) 00124 LocalFree( ConTbl->lpCompStrMem ); 00125 ConTbl->lpCompStrMem = NULL ; 00126 00127 #ifdef DEBUG_MODE 00128 { 00129 int i ; 00130 // 00131 // Reset the length of composition string to zero. 00132 // 00133 for (i = FIRSTCOL ; i < MAXCOL ; i++) { 00134 ConvertLine[i] = UNICODE_SPACE ; 00135 ConvertLineAtr[i] = 0 ; 00136 } 00137 } 00138 #endif 00139 #ifdef DEBUG_INFO 00140 xPos = FIRSTCOL; 00141 xPosLast = FIRSTCOL; 00142 HideCaret( hwnd ); 00143 DisplayConvInformation( hwnd ) ; 00144 ResetCaret( hwnd ); 00145 #endif 00146 } 00147 00148 //********************************************************************** 00149 // 00150 // void ImeUIComposition() 00151 // 00152 // This handles WM_IME_COMPOSITION message. It here just handles 00153 // composition string and result string. For normal case, it should 00154 // examine all posibile flags indicated by CompFlag, then do some 00155 // actitions to reflect what kinds of composition info. IME conversion 00156 // engine informs. 00157 // 00158 //********************************************************************** 00159 00160 void ImeUIComposition( HWND hwnd, WPARAM CompChar, LPARAM CompFlag ) 00161 { 00162 00163 DBGPRINT(("CONIME: WM_IME_COMPOSITION %08x %08x\n",CompChar,CompFlag)); 00164 00165 #ifdef DEBUG_MODE 00166 { 00167 int i ; 00168 for (i = FIRSTCOL ; i < MAXCOL ; i++) { 00169 ConvertLine[i] = UNICODE_SPACE ; 00170 ConvertLineAtr[i] = 0 ; 00171 } 00172 xPos = FIRSTCOL; 00173 xPosLast = FIRSTCOL; 00174 } 00175 #endif 00176 00177 if ( CompFlag == 0 ) { 00178 DBGPRINT((" None\n")); 00179 GetCompositionStr( hwnd, CompFlag, CompChar); 00180 } 00181 if ( CompFlag & GCS_RESULTSTR ) { 00182 DBGPRINT((" GCS_RESULTSTR\n")); 00183 GetCompositionStr( hwnd, ( CompFlag & GCS_RESULTSTR ), CompChar ); 00184 } 00185 if ( CompFlag & GCS_COMPSTR ) { 00186 DBGPRINT((" GCS_COMPSTR\n")); 00187 GetCompositionStr( hwnd, ( CompFlag & (GCS_COMPSTR|GCS_COMPATTR)), CompChar); 00188 } 00189 if ( CompFlag & CS_INSERTCHAR ) { 00190 DBGPRINT((" CS_INSERTCHAR\n")); 00191 GetCompositionStr( hwnd, ( CompFlag & (CS_INSERTCHAR|GCS_COMPATTR)), CompChar); 00192 } 00193 if ( CompFlag & CS_NOMOVECARET ) { 00194 DBGPRINT((" CS_NOMOVECARET\n")); 00195 GetCompositionStr( hwnd, ( CompFlag & (CS_NOMOVECARET|GCS_COMPATTR)), CompChar); 00196 } 00197 } 00198 00199 00200 #ifdef DEBUG_INFO 00201 //********************************************************************* 00202 // 00203 // void DisplayCompString() 00204 // 00205 // This displays composition string. 00206 // 00207 // This function send string to Console. 00208 // 00209 //********************************************************************* 00210 00211 void DisplayCompString( HWND hwnd, int Length, PWCHAR CharBuf, PUCHAR AttrBuf ) 00212 { 00213 int i; 00214 CopyMemory(ConvertLine, CharBuf, Length * sizeof(WCHAR) ) ; 00215 if ( AttrBuf == NULL ) { 00216 for ( i = 0 ; i < Length ; i++ ) 00217 ConvertLineAtr[i] = 0 ; 00218 } 00219 else { 00220 CopyMemory(ConvertLineAtr, AttrBuf, Length) ; 00221 } 00222 HideCaret( hwnd ); 00223 DisplayConvInformation( hwnd ) ; 00224 ResetCaret( hwnd ); 00225 00226 } 00227 00228 //********************************************************************* 00229 // 00230 // void DisplayResultString() 00231 // 00232 // This displays result string. 00233 // 00234 // This function supports only fixed pitch font. 00235 // 00236 //********************************************************************* 00237 00238 void DisplayResultString( HWND hwnd, LPWSTR lpwStr ) 00239 { 00240 00241 int StrLen = lstrlenW( lpwStr ); 00242 00243 CopyMemory(ConvertLine, lpwStr, StrLen*sizeof(WCHAR)) ; 00244 HideCaret( hwnd ); 00245 DisplayConvInformation( hwnd ) ; 00246 ResetCaret( hwnd ); 00247 00248 // gImeUIData.uCompLen = 0; 00249 00250 } 00251 #endif 00252 00253 //********************************************************************** 00254 // 00255 // BOOL ImeUINotify() 00256 // 00257 // This handles WM_IME_NOTIFY message. 00258 // 00259 //********************************************************************** 00260 00261 BOOL ImeUINotify( HWND hwnd, WPARAM wParam, LPARAM lParam ) 00262 { 00263 switch (wParam ) 00264 { 00265 case IMN_OPENSTATUSWINDOW: 00266 ImeUIOpenStatusWindow(hwnd) ; 00267 break; 00268 case IMN_CHANGECANDIDATE: 00269 ImeUIChangeCandidate( hwnd, (DWORD)lParam ); 00270 break; 00271 case IMN_CLOSECANDIDATE: 00272 ImeUICloseCandidate( hwnd, (DWORD)lParam ); 00273 break; 00274 case IMN_OPENCANDIDATE: 00275 ImeUIOpenCandidate( hwnd, (DWORD)lParam, TRUE); 00276 break; 00277 case IMN_SETCONVERSIONMODE: 00278 ImeUISetConversionMode(hwnd) ; 00279 // IMN_SETCONVERSIONMODE should be pass to DefWindowProc 00280 // becuase ImeNotifyHandler in User32 does notify to shell and keyboard. 00281 return FALSE; 00282 case IMN_SETOPENSTATUS: 00283 ImeUISetOpenStatus( hwnd ); 00284 // IMN_SETOPENSTATUS should be pass to DefWindowProc 00285 // becuase ImeNotifyHandler in User32 does notify to shell and keyboard. 00286 return FALSE; 00287 case IMN_GUIDELINE: 00288 ImeUIGuideLine(hwnd) ; 00289 break; 00290 default: 00291 return FALSE; 00292 00293 } 00294 return TRUE; 00295 } 00296 00297 /***************************************************************************\ 00298 * BOOL IsConsoleFullWidth(DWORD CodePage,WCHAR wch) 00299 * 00300 * Determine if the given Unicode char is fullwidth or not. 00301 * 00302 * History: 00303 * 04-08-92 ShunK Created. 00304 * Jul-27-1992 KazuM Added Screen Information and Code Page Information. 00305 * Jan-29-1992 V-Hirots Substruct Screen Information. 00306 * Oct-06-1996 KazuM Not use RtlUnicodeToMultiByteSize and WideCharToMultiByte 00307 * Because 950 only defined 13500 chars, 00308 * and unicode defined almost 18000 chars. 00309 * So there are almost 4000 chars can not be mapped to big5 code. 00310 \***************************************************************************/ 00311 00312 BOOL IsUnicodeFullWidth( 00313 IN WCHAR wch 00314 ) 00315 { 00316 if (0x20 <= wch && wch <= 0x7e) 00317 /* ASCII */ 00318 return FALSE; 00319 else if (0x3041 <= wch && wch <= 0x3094) 00320 /* Hiragana */ 00321 return TRUE; 00322 else if (0x30a1 <= wch && wch <= 0x30f6) 00323 /* Katakana */ 00324 return TRUE; 00325 else if (0x3105 <= wch && wch <= 0x312c) 00326 /* Bopomofo */ 00327 return TRUE; 00328 else if (0x3131 <= wch && wch <= 0x318e) 00329 /* Hangul Elements */ 00330 return TRUE; 00331 else if (0xac00 <= wch && wch <= 0xd7a3) 00332 /* Korean Hangul Syllables */ 00333 return TRUE; 00334 else if (0xff01 <= wch && wch <= 0xff5e) 00335 /* Fullwidth ASCII variants */ 00336 return TRUE; 00337 else if (0xff61 <= wch && wch <= 0xff9f) 00338 /* Halfwidth Katakana variants */ 00339 return FALSE; 00340 else if ( (0xffa0 <= wch && wch <= 0xffbe) || 00341 (0xffc2 <= wch && wch <= 0xffc7) || 00342 (0xffca <= wch && wch <= 0xffcf) || 00343 (0xffd2 <= wch && wch <= 0xffd7) || 00344 (0xffda <= wch && wch <= 0xffdc) ) 00345 /* Halfwidth Hangule variants */ 00346 return FALSE; 00347 else if (0xffe0 <= wch && wch <= 0xffe6) 00348 /* Fullwidth symbol variants */ 00349 return TRUE; 00350 else if (0x4e00 <= wch && wch <= 0x9fa5) 00351 /* Han Ideographic */ 00352 return TRUE; 00353 else if (0xf900 <= wch && wch <= 0xfa2d) 00354 /* Han Ideographic Compatibility */ 00355 return TRUE; 00356 else 00357 { 00358 #if 0 00359 /* 00360 * Hack this block for I don't know FONT of Console Window. 00361 * 00362 * If you would like perfect result from IsUnicodeFullWidth routine, 00363 * then you should enable this block and 00364 * you should know FONT of Console Window. 00365 */ 00366 00367 INT Width; 00368 TEXTMETRIC tmi; 00369 00370 /* Unknown character */ 00371 00372 GetTextMetricsW(hDC, &tmi); 00373 if (IS_ANY_DBCS_CHARSET(tmi.tmCharSet)) 00374 tmi.tmMaxCharWidth /= 2; 00375 00376 GetCharWidth32(hDC, wch, wch, &Width); 00377 if (Width == tmi.tmMaxCharWidth) 00378 return FALSE; 00379 else if (Width == tmi.tmMaxCharWidth*2) 00380 return TRUE; 00381 #else 00382 ULONG MultiByteSize; 00383 00384 RtlUnicodeToMultiByteSize(&MultiByteSize, &wch, sizeof(WCHAR)); 00385 if (MultiByteSize == 2) 00386 return TRUE ; 00387 else 00388 return FALSE ; 00389 #endif 00390 } 00391 ASSERT(FALSE); 00392 return FALSE; 00393 #if 0 00394 ULONG MultiByteSize; 00395 00396 RtlUnicodeToMultiByteSize(&MultiByteSize, &wch, sizeof(WCHAR)); 00397 if (MultiByteSize == 2) 00398 return TRUE ; 00399 else 00400 return FALSE ; 00401 #endif 00402 } 00403 00404 00405 BOOL 00406 ImeUIOpenStatusWindow( 00407 HWND hwnd 00408 ) 00409 { 00410 PCONSOLE_TABLE ConTbl; 00411 HIMC hIMC; // Input context handle. 00412 LPCONIME_UIMODEINFO lpModeInfo ; 00413 COPYDATASTRUCT CopyData ; 00414 00415 DBGPRINT(("CONIME: Get IMN_OPENSTATUSWINDOW Message\n")); 00416 00417 ConTbl = SearchConsole(LastConsole); 00418 if (ConTbl == NULL) { 00419 DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); 00420 return FALSE; 00421 } 00422 00423 hIMC = ImmGetContext( hwnd ) ; 00424 if ( hIMC == 0 ) 00425 return FALSE; 00426 00427 lpModeInfo = (LPCONIME_UIMODEINFO)LocalAlloc( LPTR, sizeof(CONIME_UIMODEINFO) ) ; 00428 if ( lpModeInfo == NULL) { 00429 ImmReleaseContext( hwnd, hIMC ); 00430 return FALSE; 00431 } 00432 00433 ImmGetConversionStatus(hIMC, 00434 (LPDWORD)&ConTbl->dwConversion, 00435 (LPDWORD)&ConTbl->dwSentence) ; 00436 00437 CopyData.dwData = CI_CONIMEMODEINFO ; 00438 CopyData.cbData = sizeof(CONIME_UIMODEINFO) ; 00439 CopyData.lpData = lpModeInfo ; 00440 if (ImeUIMakeInfoString(ConTbl, 00441 lpModeInfo)) 00442 { 00443 ConsoleImeSendMessage( ConTbl->hWndCon, 00444 (WPARAM)hwnd, 00445 (LPARAM)&CopyData 00446 ) ; 00447 } 00448 00449 LocalFree( lpModeInfo ); 00450 00451 ImmReleaseContext( hwnd, hIMC ); 00452 00453 return TRUE ; 00454 } 00455 00456 00457 BOOL 00458 ImeUIChangeCandidate( 00459 HWND hwnd, 00460 DWORD lParam 00461 ) 00462 { 00463 return ImeUIOpenCandidate( hwnd, lParam, FALSE) ; 00464 } 00465 00466 00467 BOOL 00468 ImeUISetOpenStatus( 00469 HWND hwnd 00470 ) 00471 { 00472 PCONSOLE_TABLE ConTbl; 00473 HIMC hIMC; // Input context handle. 00474 LPCONIME_UIMODEINFO lpModeInfo ; 00475 COPYDATASTRUCT CopyData ; 00476 00477 DBGPRINT(("CONIME: Get IMN_SETOPENSTATUS Message\n")); 00478 00479 ConTbl = SearchConsole(LastConsole); 00480 if (ConTbl == NULL) { 00481 DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); 00482 return FALSE; 00483 } 00484 00485 hIMC = ImmGetContext( hwnd ) ; 00486 if ( hIMC == 0 ) 00487 return FALSE; 00488 00489 ConTbl->fOpen = GetOpenStatusByCodepage( hIMC, ConTbl ) ; 00490 00491 ImmGetConversionStatus(hIMC, 00492 (LPDWORD)&ConTbl->dwConversion, 00493 (LPDWORD)&ConTbl->dwSentence) ; 00494 00495 if (ConTbl->ScreenBufferSize.X != 0) { 00496 00497 lpModeInfo = (LPCONIME_UIMODEINFO)LocalAlloc( LPTR, sizeof(CONIME_UIMODEINFO)) ; 00498 if ( lpModeInfo == NULL) { 00499 ImmReleaseContext( hwnd, hIMC ); 00500 return FALSE; 00501 } 00502 00503 CopyData.dwData = CI_CONIMEMODEINFO ; 00504 CopyData.cbData = sizeof(CONIME_UIMODEINFO) ; 00505 CopyData.lpData = lpModeInfo ; 00506 if (ImeUIMakeInfoString(ConTbl, 00507 lpModeInfo)) 00508 { 00509 ConsoleImeSendMessage( ConTbl->hWndCon, 00510 (WPARAM)hwnd, 00511 (LPARAM)&CopyData 00512 ) ; 00513 } 00514 LocalFree( lpModeInfo ); 00515 } 00516 ImmReleaseContext( hwnd, hIMC ); 00517 00518 return TRUE ; 00519 } 00520 00521 BOOL 00522 ImeUISetConversionMode( 00523 HWND hwnd 00524 ) 00525 { 00526 PCONSOLE_TABLE ConTbl; 00527 HIMC hIMC; // Input context handle. 00528 LPCONIME_UIMODEINFO lpModeInfo ; 00529 COPYDATASTRUCT CopyData ; 00530 DWORD OldConversion ; 00531 00532 00533 DBGPRINT(("CONIME: Get IMN_SETCONVERSIONMODE Message\n")); 00534 00535 ConTbl = SearchConsole(LastConsole); 00536 if (ConTbl == NULL) { 00537 DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); 00538 return FALSE; 00539 } 00540 00541 hIMC = ImmGetContext( hwnd ) ; 00542 if ( hIMC == 0 ) 00543 return FALSE; 00544 00545 lpModeInfo = (LPCONIME_UIMODEINFO)LocalAlloc(LPTR, sizeof(CONIME_UIMODEINFO) ) ; 00546 if ( lpModeInfo == NULL) { 00547 ImmReleaseContext( hwnd, hIMC ); 00548 return FALSE; 00549 } 00550 00551 OldConversion = ConTbl->dwConversion ; 00552 00553 ImmGetConversionStatus(hIMC, 00554 (LPDWORD)&ConTbl->dwConversion, 00555 (LPDWORD)&ConTbl->dwSentence) ; 00556 00557 CopyData.dwData = CI_CONIMEMODEINFO ; 00558 CopyData.cbData = sizeof(CONIME_UIMODEINFO) ; 00559 CopyData.lpData = lpModeInfo ; 00560 if (ImeUIMakeInfoString(ConTbl, 00561 lpModeInfo)) 00562 { 00563 ConsoleImeSendMessage( ConTbl->hWndCon, 00564 (WPARAM)hwnd, 00565 (LPARAM)&CopyData 00566 ) ; 00567 } 00568 00569 LocalFree( lpModeInfo ); 00570 ImmReleaseContext( hwnd, hIMC ); 00571 return TRUE ; 00572 00573 } 00574 00575 BOOL 00576 ImeUIGuideLine( 00577 HWND hwnd 00578 ) 00579 { 00580 PCONSOLE_TABLE ConTbl; 00581 HIMC hIMC ; // Input context handle. 00582 DWORD Level ; 00583 DWORD Index ; 00584 DWORD Length ; 00585 LPCONIME_UIMESSAGE GuideLine ; 00586 COPYDATASTRUCT CopyData ; 00587 00588 DBGPRINT(("CONIME: Get IMN_GUIDELINE Message ")); 00589 00590 ConTbl = SearchConsole(LastConsole); 00591 if (ConTbl == NULL) { 00592 DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); 00593 return FALSE; 00594 } 00595 00596 hIMC = ImmGetContext( hwnd ) ; 00597 if ( hIMC == 0 ) 00598 return FALSE; 00599 00600 Level = ImmGetGuideLine(hIMC, GGL_LEVEL, NULL, 0) ; 00601 Index = ImmGetGuideLine(hIMC, GGL_INDEX, NULL, 0) ; 00602 Length = ImmGetGuideLine(hIMC, GGL_STRING, NULL, 0) ; 00603 DBGPRINT(("Level=%d Index=%d Length=%d",Level,Index,Length)); 00604 if (Length == 0) { 00605 CopyData.dwData = CI_CONIMESYSINFO ; 00606 CopyData.cbData = Length ; 00607 CopyData.lpData = NULL ; 00608 00609 ConsoleImeSendMessage( ConTbl->hWndCon, 00610 (WPARAM)hwnd, 00611 (LPARAM)&CopyData 00612 ) ; 00613 } 00614 else{ 00615 GuideLine = (LPCONIME_UIMESSAGE)LocalAlloc(LPTR, Length + sizeof(WCHAR)) ; 00616 if (GuideLine == NULL) { 00617 ImmReleaseContext( hwnd, hIMC ); 00618 return FALSE; 00619 } 00620 00621 CopyData.dwData = CI_CONIMESYSINFO ; 00622 CopyData.cbData = Length + sizeof(WCHAR) ; 00623 CopyData.lpData = GuideLine ; 00624 Length = ImmGetGuideLine(hIMC, GGL_STRING, GuideLine->String, Length) ; 00625 00626 ConsoleImeSendMessage( ConTbl->hWndCon, 00627 (WPARAM)hwnd, 00628 (LPARAM)&CopyData 00629 ) ; 00630 00631 LocalFree( GuideLine ) ; 00632 } 00633 ImmReleaseContext( hwnd, hIMC ); 00634 DBGPRINT(("\n")); 00635 00636 return TRUE ; 00637 } 00638 00639 DWORD 00640 GetNLSMode( 00641 HWND hWnd, 00642 HANDLE hConsole 00643 ) 00644 { 00645 PCONSOLE_TABLE ConTbl; 00646 HIMC hIMC; 00647 00648 ConTbl = SearchConsole(hConsole); 00649 if (ConTbl == NULL) { 00650 DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); 00651 return 0; 00652 } 00653 00654 hIMC = ImmGetContext( hWnd ) ; 00655 if ( hIMC == (HIMC)NULL ) 00656 return IME_CMODE_DISABLE; 00657 00658 ImmGetConversionStatus(hIMC, 00659 &ConTbl->dwConversion, 00660 &ConTbl->dwSentence); 00661 ConTbl->fOpen = GetOpenStatusByCodepage( hIMC, ConTbl ) ; 00662 00663 ImmReleaseContext( hWnd, hIMC ); 00664 00665 00666 return ((ConTbl->fOpen ? IME_CMODE_OPEN : 0) + ConTbl->dwConversion); 00667 } 00668 00669 BOOL 00670 SetNLSMode( 00671 HWND hWnd, 00672 HANDLE hConsole, 00673 DWORD fdwConversion 00674 ) 00675 { 00676 PCONSOLE_TABLE ConTbl; 00677 HIMC hIMC; 00678 00679 ConTbl = SearchConsole(hConsole); 00680 if (ConTbl == NULL) { 00681 DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); 00682 return FALSE; 00683 } 00684 00685 if (fdwConversion & IME_CMODE_DISABLE) 00686 { 00687 ImmSetActiveContextConsoleIME(hWnd, FALSE) ; 00688 ImmAssociateContext(hWnd, (HIMC)NULL); 00689 ConTbl->hIMC_Current = (HIMC)NULL; 00690 } 00691 else 00692 { 00693 ImmAssociateContext(hWnd, ConTbl->hIMC_Original); 00694 ImmSetActiveContextConsoleIME(hWnd, TRUE) ; 00695 ConTbl->hIMC_Current = ConTbl->hIMC_Original; 00696 } 00697 00698 hIMC = ImmGetContext( hWnd ) ; 00699 if ( hIMC == (HIMC)NULL ) 00700 return TRUE; 00701 00702 ConTbl->fOpen =(fdwConversion & IME_CMODE_OPEN) ? TRUE : FALSE ; 00703 ImmSetOpenStatus(hIMC, ConTbl->fOpen); 00704 00705 fdwConversion &= ~(IME_CMODE_DISABLE | IME_CMODE_OPEN); 00706 if (ConTbl->dwConversion != fdwConversion) 00707 { 00708 ConTbl->dwConversion = fdwConversion; 00709 ImmSetConversionStatus(hIMC, 00710 ConTbl->dwConversion, 00711 ConTbl->dwSentence ); 00712 } 00713 00714 ImmReleaseContext( hWnd, hIMC ); 00715 00716 return TRUE; 00717 } 00718 00719 BOOL 00720 ConsoleCodepageChange( 00721 HWND hWnd, 00722 HANDLE hConsole, 00723 BOOL Output, 00724 WORD CodePage 00725 ) 00726 { 00727 PCONSOLE_TABLE ConTbl; 00728 00729 ConTbl = SearchConsole(hConsole); 00730 if (ConTbl == NULL) { 00731 DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); 00732 return FALSE; 00733 } 00734 00735 if (Output) 00736 { 00737 ConTbl->ConsoleOutputCP = CodePage ; 00738 } 00739 else 00740 { 00741 ConTbl->ConsoleCP = CodePage ; 00742 } 00743 return (TRUE) ; 00744 } 00745 00746 BOOL 00747 ImeSysPropertyWindow( 00748 HWND hWnd, 00749 WPARAM wParam, 00750 LPARAM lParam 00751 ) 00752 { 00753 PCONSOLE_TABLE ConTbl; 00754 COPYDATASTRUCT CopyData; 00755 00756 ConTbl = SearchConsole(LastConsole); 00757 if (ConTbl == NULL) { 00758 DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); 00759 return FALSE; 00760 } 00761 00762 CopyData.dwData = CI_CONIMEPROPERTYINFO; 00763 CopyData.cbData = sizeof(WPARAM); 00764 CopyData.lpData = &wParam; 00765 00766 ConsoleImeSendMessage( ConTbl->hWndCon, 00767 (WPARAM)hWnd, 00768 (LPARAM)&CopyData 00769 ); 00770 00771 return TRUE; 00772 }

Generated on Sat May 15 19:39:33 2004 for test by doxygen 1.3.7