jwaime.pas 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. {******************************************************************************}
  2. { }
  3. { IME Component API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: ime.h, released June 2000. The original Pascal }
  9. { code is: Ime.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. // $Id: JwaIme.pas,v 1.12 2007/09/14 06:48:46 marquardt Exp $
  43. {$IFNDEF JWA_OMIT_SECTIONS}
  44. unit JwaIme;
  45. {$WEAKPACKAGEUNIT}
  46. {$ENDIF JWA_OMIT_SECTIONS}
  47. {$HPPEMIT ''}
  48. {$HPPEMIT '#include "Ime.h"'}
  49. {$HPPEMIT ''}
  50. {$IFNDEF JWA_OMIT_SECTIONS}
  51. {$I jediapilib.inc}
  52. interface
  53. uses
  54. JwaWinType;
  55. {$ENDIF JWA_OMIT_SECTIONS}
  56. {$IFNDEF JWA_IMPLEMENTATIONSECTION}
  57. const
  58. IME_MAXPROCESS = 32;
  59. {$EXTERNALSYM IME_MAXPROCESS}
  60. function SendIMEMessageExA(hWnd: HWND; lParam: LPARAM): LRESULT; stdcall;
  61. {$EXTERNALSYM SendIMEMessageExA}
  62. function SendIMEMessageExW(hWnd: HWND; lParam: LPARAM): LRESULT; stdcall;
  63. {$EXTERNALSYM SendIMEMessageExW}
  64. function SendIMEMessageEx(hWnd: HWND; lParam: LPARAM): LRESULT; stdcall;
  65. {$EXTERNALSYM SendIMEMessageEx}
  66. //
  67. // IMESTRUCT structure for SendIMEMessageEx
  68. //
  69. type
  70. tagIMESTRUCT = record
  71. fnc: UINT; // function code
  72. wParam: WPARAM; // word parameter
  73. wCount: UINT; // word counter
  74. dchSource: UINT; // offset to Source from top of memory object
  75. dchDest: UINT; // offset to Desrination from top of memory object
  76. lParam1: LPARAM;
  77. lParam2: LPARAM;
  78. lParam3: LPARAM;
  79. end;
  80. {$EXTERNALSYM tagIMESTRUCT}
  81. IMESTRUCT = tagIMESTRUCT;
  82. {$EXTERNALSYM IMESTRUCT}
  83. LPIMESTRUCT = ^IMESTRUCT;
  84. {$EXTERNALSYM LPIMESTRUCT}
  85. PIMESTRUCT = ^IMESTRUCT;
  86. {$EXTERNALSYM PIMESTRUCT}
  87. NPIMESTRUCT = ^IMESTRUCT;
  88. {$EXTERNALSYM NPIMESTRUCT}
  89. TImeStruct = IMESTRUCT;
  90. const
  91. CP_HWND = 0;
  92. {$EXTERNALSYM CP_HWND}
  93. CP_OPEN = 1;
  94. {$EXTERNALSYM CP_OPEN}
  95. CP_DIRECT = 2;
  96. {$EXTERNALSYM CP_DIRECT}
  97. CP_LEVEL = 3;
  98. {$EXTERNALSYM CP_LEVEL}
  99. //
  100. // Virtual Keys
  101. //
  102. VK_DBE_ALPHANUMERIC = $0f0;
  103. {$EXTERNALSYM VK_DBE_ALPHANUMERIC}
  104. VK_DBE_KATAKANA = $0f1;
  105. {$EXTERNALSYM VK_DBE_KATAKANA}
  106. VK_DBE_HIRAGANA = $0f2;
  107. {$EXTERNALSYM VK_DBE_HIRAGANA}
  108. VK_DBE_SBCSCHAR = $0f3;
  109. {$EXTERNALSYM VK_DBE_SBCSCHAR}
  110. VK_DBE_DBCSCHAR = $0f4;
  111. {$EXTERNALSYM VK_DBE_DBCSCHAR}
  112. VK_DBE_ROMAN = $0f5;
  113. {$EXTERNALSYM VK_DBE_ROMAN}
  114. VK_DBE_NOROMAN = $0f6;
  115. {$EXTERNALSYM VK_DBE_NOROMAN}
  116. VK_DBE_ENTERWORDREGISTERMODE = $0f7;
  117. {$EXTERNALSYM VK_DBE_ENTERWORDREGISTERMODE}
  118. VK_DBE_ENTERIMECONFIGMODE = $0f8;
  119. {$EXTERNALSYM VK_DBE_ENTERIMECONFIGMODE}
  120. VK_DBE_FLUSHSTRING = $0f9;
  121. {$EXTERNALSYM VK_DBE_FLUSHSTRING}
  122. VK_DBE_CODEINPUT = $0fa;
  123. {$EXTERNALSYM VK_DBE_CODEINPUT}
  124. VK_DBE_NOCODEINPUT = $0fb;
  125. {$EXTERNALSYM VK_DBE_NOCODEINPUT}
  126. VK_DBE_DETERMINESTRING = $0fc;
  127. {$EXTERNALSYM VK_DBE_DETERMINESTRING}
  128. VK_DBE_ENTERDLGCONVERSIONMODE = $0fd;
  129. {$EXTERNALSYM VK_DBE_ENTERDLGCONVERSIONMODE}
  130. //
  131. // switch for wParam of IME_SETCONVERSIONWINDOW
  132. //
  133. MCW_DEFAULT = $00;
  134. {$EXTERNALSYM MCW_DEFAULT}
  135. MCW_RECT = $01;
  136. {$EXTERNALSYM MCW_RECT}
  137. MCW_WINDOW = $02;
  138. {$EXTERNALSYM MCW_WINDOW}
  139. MCW_SCREEN = $04;
  140. {$EXTERNALSYM MCW_SCREEN}
  141. MCW_VERTICAL = $08;
  142. {$EXTERNALSYM MCW_VERTICAL}
  143. MCW_HIDDEN = $10;
  144. {$EXTERNALSYM MCW_HIDDEN}
  145. //
  146. // switch for wParam of IME_SETCONVERSIONMODE
  147. // and IME_GETCONVERSIONMODE
  148. //
  149. IME_MODE_ALPHANUMERIC = $0001;
  150. {$EXTERNALSYM IME_MODE_ALPHANUMERIC}
  151. {$IFDEF KOREA} // BeomOh - 9/29/92
  152. IME_MODE_SBCSCHAR = $0002;
  153. {$EXTERNALSYM IME_MODE_SBCSCHAR}
  154. {$ELSE}
  155. IME_MODE_SBCSCHAR = $0008;
  156. {$EXTERNALSYM IME_MODE_SBCSCHAR}
  157. {$ENDIF KOREA}
  158. IME_MODE_KATAKANA = $0002;
  159. {$EXTERNALSYM IME_MODE_KATAKANA}
  160. IME_MODE_HIRAGANA = $0004;
  161. {$EXTERNALSYM IME_MODE_HIRAGANA}
  162. IME_MODE_HANJACONVERT = $0004;
  163. {$EXTERNALSYM IME_MODE_HANJACONVERT}
  164. IME_MODE_DBCSCHAR = $0010;
  165. {$EXTERNALSYM IME_MODE_DBCSCHAR}
  166. IME_MODE_ROMAN = $0020;
  167. {$EXTERNALSYM IME_MODE_ROMAN}
  168. IME_MODE_NOROMAN = $0040;
  169. {$EXTERNALSYM IME_MODE_NOROMAN}
  170. IME_MODE_CODEINPUT = $0080;
  171. {$EXTERNALSYM IME_MODE_CODEINPUT}
  172. IME_MODE_NOCODEINPUT = $0100;
  173. {$EXTERNALSYM IME_MODE_NOCODEINPUT}
  174. //
  175. //
  176. //
  177. // IME APIs
  178. //
  179. IME_GETIMECAPS = $03;
  180. {$EXTERNALSYM IME_GETIMECAPS}
  181. IME_SETOPEN = $04;
  182. {$EXTERNALSYM IME_SETOPEN}
  183. IME_GETOPEN = $05;
  184. {$EXTERNALSYM IME_GETOPEN}
  185. IME_GETVERSION = $07;
  186. {$EXTERNALSYM IME_GETVERSION}
  187. IME_SETCONVERSIONWINDOW = $08;
  188. {$EXTERNALSYM IME_SETCONVERSIONWINDOW}
  189. IME_MOVEIMEWINDOW = IME_SETCONVERSIONWINDOW; // KOREA only
  190. {$EXTERNALSYM IME_MOVEIMEWINDOW}
  191. IME_SETCONVERSIONMODE = $10;
  192. {$EXTERNALSYM IME_SETCONVERSIONMODE}
  193. IME_GETCONVERSIONMODE = $11;
  194. {$EXTERNALSYM IME_GETCONVERSIONMODE}
  195. IME_SET_MODE = $12; // KOREA only
  196. {$EXTERNALSYM IME_SET_MODE}
  197. IME_SENDVKEY = $13;
  198. {$EXTERNALSYM IME_SENDVKEY}
  199. IME_ENTERWORDREGISTERMODE = $18;
  200. {$EXTERNALSYM IME_ENTERWORDREGISTERMODE}
  201. IME_SETCONVERSIONFONTEX = $19;
  202. {$EXTERNALSYM IME_SETCONVERSIONFONTEX}
  203. //
  204. // IME_CODECONVERT subfunctions
  205. //
  206. IME_BANJAtoJUNJA = $13; // KOREA only
  207. {$EXTERNALSYM IME_BANJAtoJUNJA}
  208. IME_JUNJAtoBANJA = $14; // KOREA only
  209. {$EXTERNALSYM IME_JUNJAtoBANJA}
  210. IME_JOHABtoKS = $15; // KOREA only
  211. {$EXTERNALSYM IME_JOHABtoKS}
  212. IME_KStoJOHAB = $16; // KOREA only
  213. {$EXTERNALSYM IME_KStoJOHAB}
  214. //
  215. // IME_AUTOMATA subfunctions
  216. //
  217. IMEA_INIT = $01; // KOREA only
  218. {$EXTERNALSYM IMEA_INIT}
  219. IMEA_NEXT = $02; // KOREA only
  220. {$EXTERNALSYM IMEA_NEXT}
  221. IMEA_PREV = $03; // KOREA only
  222. {$EXTERNALSYM IMEA_PREV}
  223. //
  224. // IME_HANJAMODE subfunctions
  225. //
  226. IME_REQUEST_CONVERT = $01; // KOREA only
  227. {$EXTERNALSYM IME_REQUEST_CONVERT}
  228. IME_ENABLE_CONVERT = $02; // KOREA only
  229. {$EXTERNALSYM IME_ENABLE_CONVERT}
  230. //
  231. // IME_MOVEIMEWINDOW subfunctions
  232. //
  233. INTERIM_WINDOW = $00; // KOREA only
  234. {$EXTERNALSYM INTERIM_WINDOW}
  235. MODE_WINDOW = $01; // KOREA only
  236. {$EXTERNALSYM MODE_WINDOW}
  237. HANJA_WINDOW = $02; // KOREA only
  238. {$EXTERNALSYM HANJA_WINDOW}
  239. //
  240. // error code
  241. //
  242. IME_RS_ERROR = $01; // genetal error
  243. {$EXTERNALSYM IME_RS_ERROR}
  244. IME_RS_NOIME = $02; // IME is not installed
  245. {$EXTERNALSYM IME_RS_NOIME}
  246. IME_RS_TOOLONG = $05; // given string is too long
  247. {$EXTERNALSYM IME_RS_TOOLONG}
  248. IME_RS_ILLEGAL = $06; // illegal charactor(s) is string
  249. {$EXTERNALSYM IME_RS_ILLEGAL}
  250. IME_RS_NOTFOUND = $07; // no (more) candidate
  251. {$EXTERNALSYM IME_RS_NOTFOUND}
  252. IME_RS_NOROOM = $0a; // no disk/memory space
  253. {$EXTERNALSYM IME_RS_NOROOM}
  254. IME_RS_DISKERROR = $0e; // disk I/O error
  255. {$EXTERNALSYM IME_RS_DISKERROR}
  256. IME_RS_INVALID = $11; // Win3.1/NT
  257. {$EXTERNALSYM IME_RS_INVALID}
  258. IME_RS_NEST = $12; // called nested
  259. {$EXTERNALSYM IME_RS_NEST}
  260. IME_RS_SYSTEMMODAL = $13; // called when system mode
  261. {$EXTERNALSYM IME_RS_SYSTEMMODAL}
  262. //
  263. // report messge from IME to WinApps
  264. //
  265. WM_IME_REPORT = $0280;
  266. {$EXTERNALSYM WM_IME_REPORT}
  267. //
  268. // report message parameter for WM_IME_REPORT
  269. //
  270. IR_STRINGSTART = $100;
  271. {$EXTERNALSYM IR_STRINGSTART}
  272. IR_STRINGEND = $101;
  273. {$EXTERNALSYM IR_STRINGEND}
  274. IR_OPENCONVERT = $120;
  275. {$EXTERNALSYM IR_OPENCONVERT}
  276. IR_CHANGECONVERT = $121;
  277. {$EXTERNALSYM IR_CHANGECONVERT}
  278. IR_CLOSECONVERT = $122;
  279. {$EXTERNALSYM IR_CLOSECONVERT}
  280. IR_FULLCONVERT = $123;
  281. {$EXTERNALSYM IR_FULLCONVERT}
  282. IR_IMESELECT = $130;
  283. {$EXTERNALSYM IR_IMESELECT}
  284. IR_STRING = $140;
  285. {$EXTERNALSYM IR_STRING}
  286. IR_DBCSCHAR = $160;
  287. {$EXTERNALSYM IR_DBCSCHAR}
  288. IR_UNDETERMINE = $170;
  289. {$EXTERNALSYM IR_UNDETERMINE}
  290. IR_STRINGEX = $180; // New for 3.1
  291. {$EXTERNALSYM IR_STRINGEX}
  292. IR_MODEINFO = $190;
  293. {$EXTERNALSYM IR_MODEINFO}
  294. //#define WM_CONVERTREQUESTEX 0x0109
  295. WM_WNT_CONVERTREQUESTEX = $0109; // WM_CONVERTREQUESTEX: 109 for NT, 108 for OT
  296. {$EXTERNALSYM WM_WNT_CONVERTREQUESTEX}
  297. WM_CONVERTREQUEST = $010A;
  298. {$EXTERNALSYM WM_CONVERTREQUEST}
  299. WM_CONVERTRESULT = $010B;
  300. {$EXTERNALSYM WM_CONVERTRESULT}
  301. WM_INTERIM = $010C;
  302. {$EXTERNALSYM WM_INTERIM}
  303. WM_IMEKEYDOWN = $290;
  304. {$EXTERNALSYM WM_IMEKEYDOWN}
  305. WM_IMEKEYUP = $291;
  306. {$EXTERNALSYM WM_IMEKEYUP}
  307. //
  308. // UNDETERMINESTRING structure for IR_UNDETERMINE
  309. //
  310. type
  311. tagUNDETERMINESTRUCT = record
  312. dwSize: DWORD;
  313. uDefIMESize: UINT;
  314. uDefIMEPos: UINT;
  315. uUndetTextLen: UINT;
  316. uUndetTextPos: UINT;
  317. uUndetAttrPos: UINT;
  318. uCursorPos: UINT;
  319. uDeltaStart: UINT;
  320. uDetermineTextLen: UINT;
  321. uDetermineTextPos: UINT;
  322. uDetermineDelimPos: UINT;
  323. uYomiTextLen: UINT;
  324. uYomiTextPos: UINT;
  325. uYomiDelimPos: UINT;
  326. end;
  327. {$EXTERNALSYM tagUNDETERMINESTRUCT}
  328. UNDETERMINESTRUCT = tagUNDETERMINESTRUCT;
  329. {$EXTERNALSYM UNDETERMINESTRUCT}
  330. LPUNDETERMINESTRUCT = ^UNDETERMINESTRUCT;
  331. {$EXTERNALSYM LPUNDETERMINESTRUCT}
  332. PUNDETERMINESTRUCT = ^UNDETERMINESTRUCT;
  333. {$EXTERNALSYM PUNDETERMINESTRUCT}
  334. NPUNDETERMINESTRUCT = ^UNDETERMINESTRUCT;
  335. {$EXTERNALSYM NPUNDETERMINESTRUCT}
  336. TUndetermineStruct = UNDETERMINESTRUCT;
  337. tagSTRINGEXSTRUCT = record
  338. dwSize: DWORD;
  339. uDeterminePos: UINT;
  340. uDetermineDelimPos: UINT;
  341. uYomiPos: UINT;
  342. uYomiDelimPos: UINT;
  343. end;
  344. {$EXTERNALSYM tagSTRINGEXSTRUCT}
  345. STRINGEXSTRUCT = tagSTRINGEXSTRUCT;
  346. {$EXTERNALSYM STRINGEXSTRUCT}
  347. LPSTRINGEXSTRUCT = ^STRINGEXSTRUCT;
  348. {$EXTERNALSYM LPSTRINGEXSTRUCT}
  349. PSTRINGEXSTRUCT = ^STRINGEXSTRUCT;
  350. {$EXTERNALSYM PSTRINGEXSTRUCT}
  351. NPSTRINGEXSTRUCT = ^STRINGEXSTRUCT;
  352. {$EXTERNALSYM NPSTRINGEXSTRUCT}
  353. TStringexStruct = STRINGEXSTRUCT;
  354. {$ENDIF JWA_IMPLEMENTATIONSECTION}
  355. {$IFNDEF JWA_OMIT_SECTIONS}
  356. implementation
  357. //uses ...
  358. {$ENDIF JWA_OMIT_SECTIONS}
  359. {$IFNDEF JWA_INTERFACESECTION}
  360. {$IFNDEF JWA_INCLUDEMODE}
  361. const
  362. imelib = 'user32.dll';
  363. {$IFDEF UNICODE}
  364. AWSuffix = 'W';
  365. {$ELSE}
  366. AWSuffix = 'A';
  367. {$ENDIF UNICODE}
  368. {$ENDIF JWA_INCLUDEMODE}
  369. {$IFDEF DYNAMIC_LINK}
  370. var
  371. _SendIMEMessageExA: Pointer;
  372. function SendIMEMessageExA;
  373. begin
  374. GetProcedureAddress(_SendIMEMessageExA, imelib, 'SendIMEMessageExA');
  375. asm
  376. MOV ESP, EBP
  377. POP EBP
  378. JMP [_SendIMEMessageExA]
  379. end;
  380. end;
  381. var
  382. _SendIMEMessageExW: Pointer;
  383. function SendIMEMessageExW;
  384. begin
  385. GetProcedureAddress(_SendIMEMessageExW, imelib, 'SendIMEMessageExW');
  386. asm
  387. MOV ESP, EBP
  388. POP EBP
  389. JMP [_SendIMEMessageExW]
  390. end;
  391. end;
  392. var
  393. _SendIMEMessageEx: Pointer;
  394. function SendIMEMessageEx;
  395. begin
  396. GetProcedureAddress(_SendIMEMessageEx, imelib, 'SendIMEMessageEx' + AWSuffix);
  397. asm
  398. MOV ESP, EBP
  399. POP EBP
  400. JMP [_SendIMEMessageEx]
  401. end;
  402. end;
  403. {$ELSE}
  404. function SendIMEMessageExA; external imelib name 'SendIMEMessageExA';
  405. function SendIMEMessageExW; external imelib name 'SendIMEMessageExW';
  406. function SendIMEMessageEx; external imelib name 'SendIMEMessageEx' + AWSuffix;
  407. {$ENDIF DYNAMIC_LINK}
  408. {$ENDIF JWA_INTERFACESECTION}
  409. {$IFNDEF JWA_OMIT_SECTIONS}
  410. end.
  411. {$ENDIF JWA_OMIT_SECTIONS}