Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

772 lines
20 KiB

  1. // Copyright (c) 1985 - 1999, Microsoft Corporation
  2. //
  3. // MODULE: ConSubs.c
  4. //
  5. // PURPOSE: Console IME control.
  6. //
  7. // PLATFORMS: Windows NT-FE 3.51
  8. //
  9. // FUNCTIONS:
  10. //
  11. // History:
  12. //
  13. // 27.Jul.1995 v-HirShi (Hirotoshi Shimizu) created
  14. // 10.Jul.1996 v-HirShi (Hirotoshi Shimizu) adupt FE edition
  15. //
  16. // COMMENTS:
  17. //
  18. #include "precomp.h"
  19. #pragma hdrstop
  20. INT
  21. Create( HWND hWnd )
  22. {
  23. ghDefaultIMC = ImmGetContext(hWnd) ;
  24. #ifdef DEBUG_MODE
  25. {
  26. //
  27. // Select fixed pitch system font and get its text metrics
  28. //
  29. HDC hdc;
  30. TEXTMETRIC tm;
  31. WORD patern = 0xA4A4;
  32. SIZE size;
  33. HFONT hfntFixed; // fixed-pitch font
  34. HFONT hfntOld; // default font holder
  35. hdc = GetDC( hWnd );
  36. hfntFixed = GetStockObject( SYSTEM_FIXED_FONT );
  37. hfntOld = SelectObject( hdc, hfntFixed );
  38. GetTextMetrics( hdc, &tm );
  39. GetTextExtentPoint32( hdc, (LPWSTR)&patern, sizeof(WORD), (LPSIZE) &size );
  40. cxMetrics = (UINT) size.cx / 2;
  41. cyMetrics = (UINT) size.cy;
  42. ReleaseDC( hWnd, hdc );
  43. xPos = 0 ;
  44. CaretWidth = GetSystemMetrics( SM_CXBORDER );
  45. }
  46. #endif
  47. return 0;
  48. }
  49. //**********************************************************************
  50. //
  51. // void ImeUIStartComposition()
  52. //
  53. // This handles WM_IME_STARTCOMPOSITION message.
  54. //
  55. //**********************************************************************
  56. void ImeUIStartComposition( HWND hwnd )
  57. {
  58. PCONSOLE_TABLE ConTbl;
  59. ConTbl = SearchConsole(LastConsole);
  60. if (ConTbl == NULL) {
  61. DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
  62. return;
  63. }
  64. //
  65. // Set fInComposition variables.
  66. //
  67. ConTbl->fInComposition = TRUE;
  68. #ifdef DEBUG_MODE
  69. {
  70. int i ;
  71. for (i = FIRSTCOL ; i < MAXCOL ; i++) {
  72. ConvertLine[i] = UNICODE_SPACE ;
  73. ConvertLineAtr[i] = 0 ;
  74. }
  75. }
  76. #endif
  77. #ifdef DEBUG_INFO
  78. xPos = FIRSTCOL;
  79. xPosLast = FIRSTCOL;
  80. HideCaret( hwnd );
  81. DisplayConvInformation( hwnd ) ;
  82. ResetCaret( hwnd );
  83. #endif
  84. }
  85. //**********************************************************************
  86. //
  87. // void ImeUIEndComposition
  88. //
  89. // This handles WM_IME_ENDCOMPOSITION message.
  90. //
  91. //**********************************************************************
  92. void ImeUIEndComposition( HWND hwnd )
  93. {
  94. PCONSOLE_TABLE ConTbl;
  95. ConTbl = SearchConsole(LastConsole);
  96. if (ConTbl == NULL) {
  97. DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
  98. return;
  99. }
  100. //
  101. // Reset fInComposition variables.
  102. //
  103. ConTbl->fInComposition = FALSE;
  104. if (ConTbl->lpCompStrMem)
  105. LocalFree( ConTbl->lpCompStrMem );
  106. ConTbl->lpCompStrMem = NULL ;
  107. #ifdef DEBUG_MODE
  108. {
  109. int i ;
  110. //
  111. // Reset the length of composition string to zero.
  112. //
  113. for (i = FIRSTCOL ; i < MAXCOL ; i++) {
  114. ConvertLine[i] = UNICODE_SPACE ;
  115. ConvertLineAtr[i] = 0 ;
  116. }
  117. }
  118. #endif
  119. #ifdef DEBUG_INFO
  120. xPos = FIRSTCOL;
  121. xPosLast = FIRSTCOL;
  122. HideCaret( hwnd );
  123. DisplayConvInformation( hwnd ) ;
  124. ResetCaret( hwnd );
  125. #endif
  126. }
  127. //**********************************************************************
  128. //
  129. // void ImeUIComposition()
  130. //
  131. // This handles WM_IME_COMPOSITION message. It here just handles
  132. // composition string and result string. For normal case, it should
  133. // examine all posibile flags indicated by CompFlag, then do some
  134. // actitions to reflect what kinds of composition info. IME conversion
  135. // engine informs.
  136. //
  137. //**********************************************************************
  138. void ImeUIComposition( HWND hwnd, WPARAM CompChar, LPARAM CompFlag )
  139. {
  140. DBGPRINT(("CONIME: WM_IME_COMPOSITION %08x %08x\n",CompChar,CompFlag));
  141. #ifdef DEBUG_MODE
  142. {
  143. int i ;
  144. for (i = FIRSTCOL ; i < MAXCOL ; i++) {
  145. ConvertLine[i] = UNICODE_SPACE ;
  146. ConvertLineAtr[i] = 0 ;
  147. }
  148. xPos = FIRSTCOL;
  149. xPosLast = FIRSTCOL;
  150. }
  151. #endif
  152. if ( CompFlag == 0 ) {
  153. DBGPRINT((" None\n"));
  154. GetCompositionStr( hwnd, CompFlag, CompChar);
  155. }
  156. if ( CompFlag & GCS_RESULTSTR ) {
  157. DBGPRINT((" GCS_RESULTSTR\n"));
  158. GetCompositionStr( hwnd, ( CompFlag & GCS_RESULTSTR ), CompChar );
  159. }
  160. if ( CompFlag & GCS_COMPSTR ) {
  161. DBGPRINT((" GCS_COMPSTR\n"));
  162. GetCompositionStr( hwnd, ( CompFlag & (GCS_COMPSTR|GCS_COMPATTR)), CompChar);
  163. }
  164. if ( CompFlag & CS_INSERTCHAR ) {
  165. DBGPRINT((" CS_INSERTCHAR\n"));
  166. GetCompositionStr( hwnd, ( CompFlag & (CS_INSERTCHAR|GCS_COMPATTR)), CompChar);
  167. }
  168. if ( CompFlag & CS_NOMOVECARET ) {
  169. DBGPRINT((" CS_NOMOVECARET\n"));
  170. GetCompositionStr( hwnd, ( CompFlag & (CS_NOMOVECARET|GCS_COMPATTR)), CompChar);
  171. }
  172. }
  173. #ifdef DEBUG_INFO
  174. //*********************************************************************
  175. //
  176. // void DisplayCompString()
  177. //
  178. // This displays composition string.
  179. //
  180. // This function send string to Console.
  181. //
  182. //*********************************************************************
  183. void DisplayCompString( HWND hwnd, int Length, PWCHAR CharBuf, PUCHAR AttrBuf )
  184. {
  185. int i;
  186. CopyMemory(ConvertLine, CharBuf, Length * sizeof(WCHAR) ) ;
  187. if ( AttrBuf == NULL ) {
  188. for ( i = 0 ; i < Length ; i++ )
  189. ConvertLineAtr[i] = 0 ;
  190. }
  191. else {
  192. CopyMemory(ConvertLineAtr, AttrBuf, Length) ;
  193. }
  194. HideCaret( hwnd );
  195. DisplayConvInformation( hwnd ) ;
  196. ResetCaret( hwnd );
  197. }
  198. //*********************************************************************
  199. //
  200. // void DisplayResultString()
  201. //
  202. // This displays result string.
  203. //
  204. // This function supports only fixed pitch font.
  205. //
  206. //*********************************************************************
  207. void DisplayResultString( HWND hwnd, LPWSTR lpwStr )
  208. {
  209. int StrLen = lstrlenW( lpwStr );
  210. CopyMemory(ConvertLine, lpwStr, StrLen*sizeof(WCHAR)) ;
  211. HideCaret( hwnd );
  212. DisplayConvInformation( hwnd ) ;
  213. ResetCaret( hwnd );
  214. // gImeUIData.uCompLen = 0;
  215. }
  216. #endif
  217. //**********************************************************************
  218. //
  219. // BOOL ImeUINotify()
  220. //
  221. // This handles WM_IME_NOTIFY message.
  222. //
  223. //**********************************************************************
  224. BOOL ImeUINotify( HWND hwnd, WPARAM wParam, LPARAM lParam )
  225. {
  226. switch (wParam )
  227. {
  228. case IMN_OPENSTATUSWINDOW:
  229. ImeUIOpenStatusWindow(hwnd) ;
  230. break;
  231. case IMN_CHANGECANDIDATE:
  232. ImeUIChangeCandidate( hwnd, (DWORD)lParam );
  233. break;
  234. case IMN_CLOSECANDIDATE:
  235. ImeUICloseCandidate( hwnd, (DWORD)lParam );
  236. break;
  237. case IMN_OPENCANDIDATE:
  238. ImeUIOpenCandidate( hwnd, (DWORD)lParam, TRUE);
  239. break;
  240. case IMN_SETCONVERSIONMODE:
  241. ImeUISetConversionMode(hwnd) ;
  242. // IMN_SETCONVERSIONMODE should be pass to DefWindowProc
  243. // becuase ImeNotifyHandler in User32 does notify to shell and keyboard.
  244. return FALSE;
  245. case IMN_SETOPENSTATUS:
  246. ImeUISetOpenStatus( hwnd );
  247. // IMN_SETOPENSTATUS should be pass to DefWindowProc
  248. // becuase ImeNotifyHandler in User32 does notify to shell and keyboard.
  249. return FALSE;
  250. case IMN_GUIDELINE:
  251. ImeUIGuideLine(hwnd) ;
  252. break;
  253. default:
  254. return FALSE;
  255. }
  256. return TRUE;
  257. }
  258. /***************************************************************************\
  259. * BOOL IsConsoleFullWidth(DWORD CodePage,WCHAR wch)
  260. *
  261. * Determine if the given Unicode char is fullwidth or not.
  262. *
  263. * History:
  264. * 04-08-92 ShunK Created.
  265. * Jul-27-1992 KazuM Added Screen Information and Code Page Information.
  266. * Jan-29-1992 V-Hirots Substruct Screen Information.
  267. * Oct-06-1996 KazuM Not use RtlUnicodeToMultiByteSize and WideCharToMultiByte
  268. * Because 950 only defined 13500 chars,
  269. * and unicode defined almost 18000 chars.
  270. * So there are almost 4000 chars can not be mapped to big5 code.
  271. \***************************************************************************/
  272. BOOL IsUnicodeFullWidth(
  273. IN WCHAR wch
  274. )
  275. {
  276. if (0x20 <= wch && wch <= 0x7e)
  277. /* ASCII */
  278. return FALSE;
  279. else if (0x3041 <= wch && wch <= 0x3094)
  280. /* Hiragana */
  281. return TRUE;
  282. else if (0x30a1 <= wch && wch <= 0x30f6)
  283. /* Katakana */
  284. return TRUE;
  285. else if (0x3105 <= wch && wch <= 0x312c)
  286. /* Bopomofo */
  287. return TRUE;
  288. else if (0x3131 <= wch && wch <= 0x318e)
  289. /* Hangul Elements */
  290. return TRUE;
  291. else if (0xac00 <= wch && wch <= 0xd7a3)
  292. /* Korean Hangul Syllables */
  293. return TRUE;
  294. else if (0xff01 <= wch && wch <= 0xff5e)
  295. /* Fullwidth ASCII variants */
  296. return TRUE;
  297. else if (0xff61 <= wch && wch <= 0xff9f)
  298. /* Halfwidth Katakana variants */
  299. return FALSE;
  300. else if ( (0xffa0 <= wch && wch <= 0xffbe) ||
  301. (0xffc2 <= wch && wch <= 0xffc7) ||
  302. (0xffca <= wch && wch <= 0xffcf) ||
  303. (0xffd2 <= wch && wch <= 0xffd7) ||
  304. (0xffda <= wch && wch <= 0xffdc) )
  305. /* Halfwidth Hangule variants */
  306. return FALSE;
  307. else if (0xffe0 <= wch && wch <= 0xffe6)
  308. /* Fullwidth symbol variants */
  309. return TRUE;
  310. else if (0x4e00 <= wch && wch <= 0x9fa5)
  311. /* Han Ideographic */
  312. return TRUE;
  313. else if (0xf900 <= wch && wch <= 0xfa2d)
  314. /* Han Ideographic Compatibility */
  315. return TRUE;
  316. else
  317. {
  318. #if 0
  319. /*
  320. * Hack this block for I don't know FONT of Console Window.
  321. *
  322. * If you would like perfect result from IsUnicodeFullWidth routine,
  323. * then you should enable this block and
  324. * you should know FONT of Console Window.
  325. */
  326. INT Width;
  327. TEXTMETRIC tmi;
  328. /* Unknown character */
  329. GetTextMetricsW(hDC, &tmi);
  330. if (IS_ANY_DBCS_CHARSET(tmi.tmCharSet))
  331. tmi.tmMaxCharWidth /= 2;
  332. GetCharWidth32(hDC, wch, wch, &Width);
  333. if (Width == tmi.tmMaxCharWidth)
  334. return FALSE;
  335. else if (Width == tmi.tmMaxCharWidth*2)
  336. return TRUE;
  337. #else
  338. ULONG MultiByteSize;
  339. RtlUnicodeToMultiByteSize(&MultiByteSize, &wch, sizeof(WCHAR));
  340. if (MultiByteSize == 2)
  341. return TRUE ;
  342. else
  343. return FALSE ;
  344. #endif
  345. }
  346. ASSERT(FALSE);
  347. return FALSE;
  348. #if 0
  349. ULONG MultiByteSize;
  350. RtlUnicodeToMultiByteSize(&MultiByteSize, &wch, sizeof(WCHAR));
  351. if (MultiByteSize == 2)
  352. return TRUE ;
  353. else
  354. return FALSE ;
  355. #endif
  356. }
  357. BOOL
  358. ImeUIOpenStatusWindow(
  359. HWND hwnd
  360. )
  361. {
  362. PCONSOLE_TABLE ConTbl;
  363. HIMC hIMC; // Input context handle.
  364. LPCONIME_UIMODEINFO lpModeInfo ;
  365. COPYDATASTRUCT CopyData ;
  366. DBGPRINT(("CONIME: Get IMN_OPENSTATUSWINDOW Message\n"));
  367. ConTbl = SearchConsole(LastConsole);
  368. if (ConTbl == NULL) {
  369. DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
  370. return FALSE;
  371. }
  372. hIMC = ImmGetContext( hwnd ) ;
  373. if ( hIMC == 0 )
  374. return FALSE;
  375. lpModeInfo = (LPCONIME_UIMODEINFO)LocalAlloc( LPTR, sizeof(CONIME_UIMODEINFO) ) ;
  376. if ( lpModeInfo == NULL) {
  377. ImmReleaseContext( hwnd, hIMC );
  378. return FALSE;
  379. }
  380. ImmGetConversionStatus(hIMC,
  381. (LPDWORD)&ConTbl->dwConversion,
  382. (LPDWORD)&ConTbl->dwSentence) ;
  383. CopyData.dwData = CI_CONIMEMODEINFO ;
  384. CopyData.cbData = sizeof(CONIME_UIMODEINFO) ;
  385. CopyData.lpData = lpModeInfo ;
  386. if (ImeUIMakeInfoString(ConTbl,
  387. lpModeInfo))
  388. {
  389. ConsoleImeSendMessage( ConTbl->hWndCon,
  390. (WPARAM)hwnd,
  391. (LPARAM)&CopyData
  392. ) ;
  393. }
  394. LocalFree( lpModeInfo );
  395. ImmReleaseContext( hwnd, hIMC );
  396. return TRUE ;
  397. }
  398. BOOL
  399. ImeUIChangeCandidate(
  400. HWND hwnd,
  401. DWORD lParam
  402. )
  403. {
  404. return ImeUIOpenCandidate( hwnd, lParam, FALSE) ;
  405. }
  406. BOOL
  407. ImeUISetOpenStatus(
  408. HWND hwnd
  409. )
  410. {
  411. PCONSOLE_TABLE ConTbl;
  412. HIMC hIMC; // Input context handle.
  413. LPCONIME_UIMODEINFO lpModeInfo ;
  414. COPYDATASTRUCT CopyData ;
  415. DBGPRINT(("CONIME: Get IMN_SETOPENSTATUS Message\n"));
  416. ConTbl = SearchConsole(LastConsole);
  417. if (ConTbl == NULL) {
  418. DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
  419. return FALSE;
  420. }
  421. hIMC = ImmGetContext( hwnd ) ;
  422. if ( hIMC == 0 )
  423. return FALSE;
  424. ConTbl->fOpen = GetOpenStatusByCodepage( hIMC, ConTbl ) ;
  425. ImmGetConversionStatus(hIMC,
  426. (LPDWORD)&ConTbl->dwConversion,
  427. (LPDWORD)&ConTbl->dwSentence) ;
  428. if (ConTbl->ScreenBufferSize.X != 0) {
  429. lpModeInfo = (LPCONIME_UIMODEINFO)LocalAlloc( LPTR, sizeof(CONIME_UIMODEINFO)) ;
  430. if ( lpModeInfo == NULL) {
  431. ImmReleaseContext( hwnd, hIMC );
  432. return FALSE;
  433. }
  434. CopyData.dwData = CI_CONIMEMODEINFO ;
  435. CopyData.cbData = sizeof(CONIME_UIMODEINFO) ;
  436. CopyData.lpData = lpModeInfo ;
  437. if (ImeUIMakeInfoString(ConTbl,
  438. lpModeInfo))
  439. {
  440. ConsoleImeSendMessage( ConTbl->hWndCon,
  441. (WPARAM)hwnd,
  442. (LPARAM)&CopyData
  443. ) ;
  444. }
  445. LocalFree( lpModeInfo );
  446. }
  447. ImmReleaseContext( hwnd, hIMC );
  448. return TRUE ;
  449. }
  450. BOOL
  451. ImeUISetConversionMode(
  452. HWND hwnd
  453. )
  454. {
  455. PCONSOLE_TABLE ConTbl;
  456. HIMC hIMC; // Input context handle.
  457. LPCONIME_UIMODEINFO lpModeInfo ;
  458. COPYDATASTRUCT CopyData ;
  459. DWORD OldConversion ;
  460. DBGPRINT(("CONIME: Get IMN_SETCONVERSIONMODE Message\n"));
  461. ConTbl = SearchConsole(LastConsole);
  462. if (ConTbl == NULL) {
  463. DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
  464. return FALSE;
  465. }
  466. hIMC = ImmGetContext( hwnd ) ;
  467. if ( hIMC == 0 )
  468. return FALSE;
  469. lpModeInfo = (LPCONIME_UIMODEINFO)LocalAlloc(LPTR, sizeof(CONIME_UIMODEINFO) ) ;
  470. if ( lpModeInfo == NULL) {
  471. ImmReleaseContext( hwnd, hIMC );
  472. return FALSE;
  473. }
  474. OldConversion = ConTbl->dwConversion ;
  475. ImmGetConversionStatus(hIMC,
  476. (LPDWORD)&ConTbl->dwConversion,
  477. (LPDWORD)&ConTbl->dwSentence) ;
  478. CopyData.dwData = CI_CONIMEMODEINFO ;
  479. CopyData.cbData = sizeof(CONIME_UIMODEINFO) ;
  480. CopyData.lpData = lpModeInfo ;
  481. if (ImeUIMakeInfoString(ConTbl,
  482. lpModeInfo))
  483. {
  484. ConsoleImeSendMessage( ConTbl->hWndCon,
  485. (WPARAM)hwnd,
  486. (LPARAM)&CopyData
  487. ) ;
  488. }
  489. LocalFree( lpModeInfo );
  490. ImmReleaseContext( hwnd, hIMC );
  491. return TRUE ;
  492. }
  493. BOOL
  494. ImeUIGuideLine(
  495. HWND hwnd
  496. )
  497. {
  498. PCONSOLE_TABLE ConTbl;
  499. HIMC hIMC ; // Input context handle.
  500. DWORD Level ;
  501. DWORD Index ;
  502. DWORD Length ;
  503. LPCONIME_UIMESSAGE GuideLine ;
  504. COPYDATASTRUCT CopyData ;
  505. DBGPRINT(("CONIME: Get IMN_GUIDELINE Message "));
  506. ConTbl = SearchConsole(LastConsole);
  507. if (ConTbl == NULL) {
  508. DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
  509. return FALSE;
  510. }
  511. hIMC = ImmGetContext( hwnd ) ;
  512. if ( hIMC == 0 )
  513. return FALSE;
  514. Level = ImmGetGuideLine(hIMC, GGL_LEVEL, NULL, 0) ;
  515. Index = ImmGetGuideLine(hIMC, GGL_INDEX, NULL, 0) ;
  516. Length = ImmGetGuideLine(hIMC, GGL_STRING, NULL, 0) ;
  517. DBGPRINT(("Level=%d Index=%d Length=%d",Level,Index,Length));
  518. if (Length == 0) {
  519. CopyData.dwData = CI_CONIMESYSINFO ;
  520. CopyData.cbData = Length ;
  521. CopyData.lpData = NULL ;
  522. ConsoleImeSendMessage( ConTbl->hWndCon,
  523. (WPARAM)hwnd,
  524. (LPARAM)&CopyData
  525. ) ;
  526. }
  527. else{
  528. GuideLine = (LPCONIME_UIMESSAGE)LocalAlloc(LPTR, Length + sizeof(WCHAR)) ;
  529. if (GuideLine == NULL) {
  530. ImmReleaseContext( hwnd, hIMC );
  531. return FALSE;
  532. }
  533. CopyData.dwData = CI_CONIMESYSINFO ;
  534. CopyData.cbData = Length + sizeof(WCHAR) ;
  535. CopyData.lpData = GuideLine ;
  536. Length = ImmGetGuideLine(hIMC, GGL_STRING, GuideLine->String, Length) ;
  537. ConsoleImeSendMessage( ConTbl->hWndCon,
  538. (WPARAM)hwnd,
  539. (LPARAM)&CopyData
  540. ) ;
  541. LocalFree( GuideLine ) ;
  542. }
  543. ImmReleaseContext( hwnd, hIMC );
  544. DBGPRINT(("\n"));
  545. return TRUE ;
  546. }
  547. DWORD
  548. GetNLSMode(
  549. HWND hWnd,
  550. HANDLE hConsole
  551. )
  552. {
  553. PCONSOLE_TABLE ConTbl;
  554. HIMC hIMC;
  555. ConTbl = SearchConsole(hConsole);
  556. if (ConTbl == NULL) {
  557. DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
  558. return 0;
  559. }
  560. hIMC = ImmGetContext( hWnd ) ;
  561. if ( hIMC == (HIMC)NULL )
  562. return IME_CMODE_DISABLE;
  563. ImmGetConversionStatus(hIMC,
  564. &ConTbl->dwConversion,
  565. &ConTbl->dwSentence);
  566. ConTbl->fOpen = GetOpenStatusByCodepage( hIMC, ConTbl ) ;
  567. ImmReleaseContext( hWnd, hIMC );
  568. return ((ConTbl->fOpen ? IME_CMODE_OPEN : 0) + ConTbl->dwConversion);
  569. }
  570. BOOL
  571. SetNLSMode(
  572. HWND hWnd,
  573. HANDLE hConsole,
  574. DWORD fdwConversion
  575. )
  576. {
  577. PCONSOLE_TABLE ConTbl;
  578. HIMC hIMC;
  579. ConTbl = SearchConsole(hConsole);
  580. if (ConTbl == NULL) {
  581. DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
  582. return FALSE;
  583. }
  584. if (fdwConversion & IME_CMODE_DISABLE)
  585. {
  586. ImmSetActiveContextConsoleIME(hWnd, FALSE) ;
  587. ImmAssociateContext(hWnd, (HIMC)NULL);
  588. ConTbl->hIMC_Current = (HIMC)NULL;
  589. }
  590. else
  591. {
  592. ImmAssociateContext(hWnd, ConTbl->hIMC_Original);
  593. ImmSetActiveContextConsoleIME(hWnd, TRUE) ;
  594. ConTbl->hIMC_Current = ConTbl->hIMC_Original;
  595. }
  596. hIMC = ImmGetContext( hWnd ) ;
  597. if ( hIMC == (HIMC)NULL )
  598. return TRUE;
  599. ConTbl->fOpen =(fdwConversion & IME_CMODE_OPEN) ? TRUE : FALSE ;
  600. ImmSetOpenStatus(hIMC, ConTbl->fOpen);
  601. fdwConversion &= ~(IME_CMODE_DISABLE | IME_CMODE_OPEN);
  602. if (ConTbl->dwConversion != fdwConversion)
  603. {
  604. ConTbl->dwConversion = fdwConversion;
  605. ImmSetConversionStatus(hIMC,
  606. ConTbl->dwConversion,
  607. ConTbl->dwSentence );
  608. }
  609. ImmReleaseContext( hWnd, hIMC );
  610. return TRUE;
  611. }
  612. BOOL
  613. ConsoleCodepageChange(
  614. HWND hWnd,
  615. HANDLE hConsole,
  616. BOOL Output,
  617. WORD CodePage
  618. )
  619. {
  620. PCONSOLE_TABLE ConTbl;
  621. ConTbl = SearchConsole(hConsole);
  622. if (ConTbl == NULL) {
  623. DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
  624. return FALSE;
  625. }
  626. if (Output)
  627. {
  628. ConTbl->ConsoleOutputCP = CodePage ;
  629. }
  630. else
  631. {
  632. ConTbl->ConsoleCP = CodePage ;
  633. }
  634. return (TRUE) ;
  635. }
  636. BOOL
  637. ImeSysPropertyWindow(
  638. HWND hWnd,
  639. WPARAM wParam,
  640. LPARAM lParam
  641. )
  642. {
  643. PCONSOLE_TABLE ConTbl;
  644. COPYDATASTRUCT CopyData;
  645. ConTbl = SearchConsole(LastConsole);
  646. if (ConTbl == NULL) {
  647. DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
  648. return FALSE;
  649. }
  650. CopyData.dwData = CI_CONIMEPROPERTYINFO;
  651. CopyData.cbData = sizeof(WPARAM);
  652. CopyData.lpData = &wParam;
  653. ConsoleImeSendMessage( ConTbl->hWndCon,
  654. (WPARAM)hWnd,
  655. (LPARAM)&CopyData
  656. );
  657. return TRUE;
  658. }