jwaime.pas 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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. unit JwaIme;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "Ime.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaWinType;
  51. const
  52. IME_MAXPROCESS = 32;
  53. {$EXTERNALSYM IME_MAXPROCESS}
  54. function SendIMEMessageExA(hWnd: HWND; lParam: LPARAM): LRESULT; stdcall;
  55. {$EXTERNALSYM SendIMEMessageExA}
  56. function SendIMEMessageExW(hWnd: HWND; lParam: LPARAM): LRESULT; stdcall;
  57. {$EXTERNALSYM SendIMEMessageExW}
  58. function SendIMEMessageEx(hWnd: HWND; lParam: LPARAM): LRESULT; stdcall;
  59. {$EXTERNALSYM SendIMEMessageEx}
  60. //
  61. // IMESTRUCT structure for SendIMEMessageEx
  62. //
  63. type
  64. tagIMESTRUCT = record
  65. fnc: UINT; // function code
  66. wParam: WPARAM; // word parameter
  67. wCount: UINT; // word counter
  68. dchSource: UINT; // offset to Source from top of memory object
  69. dchDest: UINT; // offset to Desrination from top of memory object
  70. lParam1: LPARAM;
  71. lParam2: LPARAM;
  72. lParam3: LPARAM;
  73. end;
  74. {$EXTERNALSYM tagIMESTRUCT}
  75. IMESTRUCT = tagIMESTRUCT;
  76. {$EXTERNALSYM IMESTRUCT}
  77. LPIMESTRUCT = ^IMESTRUCT;
  78. {$EXTERNALSYM LPIMESTRUCT}
  79. PIMESTRUCT = ^IMESTRUCT;
  80. {$EXTERNALSYM PIMESTRUCT}
  81. NPIMESTRUCT = ^IMESTRUCT;
  82. {$EXTERNALSYM NPIMESTRUCT}
  83. TImeStruct = IMESTRUCT;
  84. const
  85. CP_HWND = 0;
  86. {$EXTERNALSYM CP_HWND}
  87. CP_OPEN = 1;
  88. {$EXTERNALSYM CP_OPEN}
  89. CP_DIRECT = 2;
  90. {$EXTERNALSYM CP_DIRECT}
  91. CP_LEVEL = 3;
  92. {$EXTERNALSYM CP_LEVEL}
  93. //
  94. // Virtual Keys
  95. //
  96. VK_DBE_ALPHANUMERIC = $0f0;
  97. {$EXTERNALSYM VK_DBE_ALPHANUMERIC}
  98. VK_DBE_KATAKANA = $0f1;
  99. {$EXTERNALSYM VK_DBE_KATAKANA}
  100. VK_DBE_HIRAGANA = $0f2;
  101. {$EXTERNALSYM VK_DBE_HIRAGANA}
  102. VK_DBE_SBCSCHAR = $0f3;
  103. {$EXTERNALSYM VK_DBE_SBCSCHAR}
  104. VK_DBE_DBCSCHAR = $0f4;
  105. {$EXTERNALSYM VK_DBE_DBCSCHAR}
  106. VK_DBE_ROMAN = $0f5;
  107. {$EXTERNALSYM VK_DBE_ROMAN}
  108. VK_DBE_NOROMAN = $0f6;
  109. {$EXTERNALSYM VK_DBE_NOROMAN}
  110. VK_DBE_ENTERWORDREGISTERMODE = $0f7;
  111. {$EXTERNALSYM VK_DBE_ENTERWORDREGISTERMODE}
  112. VK_DBE_ENTERIMECONFIGMODE = $0f8;
  113. {$EXTERNALSYM VK_DBE_ENTERIMECONFIGMODE}
  114. VK_DBE_FLUSHSTRING = $0f9;
  115. {$EXTERNALSYM VK_DBE_FLUSHSTRING}
  116. VK_DBE_CODEINPUT = $0fa;
  117. {$EXTERNALSYM VK_DBE_CODEINPUT}
  118. VK_DBE_NOCODEINPUT = $0fb;
  119. {$EXTERNALSYM VK_DBE_NOCODEINPUT}
  120. VK_DBE_DETERMINESTRING = $0fc;
  121. {$EXTERNALSYM VK_DBE_DETERMINESTRING}
  122. VK_DBE_ENTERDLGCONVERSIONMODE = $0fd;
  123. {$EXTERNALSYM VK_DBE_ENTERDLGCONVERSIONMODE}
  124. //
  125. // switch for wParam of IME_SETCONVERSIONWINDOW
  126. //
  127. MCW_DEFAULT = $00;
  128. {$EXTERNALSYM MCW_DEFAULT}
  129. MCW_RECT = $01;
  130. {$EXTERNALSYM MCW_RECT}
  131. MCW_WINDOW = $02;
  132. {$EXTERNALSYM MCW_WINDOW}
  133. MCW_SCREEN = $04;
  134. {$EXTERNALSYM MCW_SCREEN}
  135. MCW_VERTICAL = $08;
  136. {$EXTERNALSYM MCW_VERTICAL}
  137. MCW_HIDDEN = $10;
  138. {$EXTERNALSYM MCW_HIDDEN}
  139. //
  140. // switch for wParam of IME_SETCONVERSIONMODE
  141. // and IME_GETCONVERSIONMODE
  142. //
  143. IME_MODE_ALPHANUMERIC = $0001;
  144. {$EXTERNALSYM IME_MODE_ALPHANUMERIC}
  145. {$IFDEF KOREA} // BeomOh - 9/29/92
  146. IME_MODE_SBCSCHAR = $0002;
  147. {$EXTERNALSYM IME_MODE_SBCSCHAR}
  148. {$ELSE}
  149. IME_MODE_SBCSCHAR = $0008;
  150. {$EXTERNALSYM IME_MODE_SBCSCHAR}
  151. {$ENDIF KOREA}
  152. IME_MODE_KATAKANA = $0002;
  153. {$EXTERNALSYM IME_MODE_KATAKANA}
  154. IME_MODE_HIRAGANA = $0004;
  155. {$EXTERNALSYM IME_MODE_HIRAGANA}
  156. IME_MODE_HANJACONVERT = $0004;
  157. {$EXTERNALSYM IME_MODE_HANJACONVERT}
  158. IME_MODE_DBCSCHAR = $0010;
  159. {$EXTERNALSYM IME_MODE_DBCSCHAR}
  160. IME_MODE_ROMAN = $0020;
  161. {$EXTERNALSYM IME_MODE_ROMAN}
  162. IME_MODE_NOROMAN = $0040;
  163. {$EXTERNALSYM IME_MODE_NOROMAN}
  164. IME_MODE_CODEINPUT = $0080;
  165. {$EXTERNALSYM IME_MODE_CODEINPUT}
  166. IME_MODE_NOCODEINPUT = $0100;
  167. {$EXTERNALSYM IME_MODE_NOCODEINPUT}
  168. //
  169. //
  170. //
  171. // IME APIs
  172. //
  173. IME_GETIMECAPS = $03;
  174. {$EXTERNALSYM IME_GETIMECAPS}
  175. IME_SETOPEN = $04;
  176. {$EXTERNALSYM IME_SETOPEN}
  177. IME_GETOPEN = $05;
  178. {$EXTERNALSYM IME_GETOPEN}
  179. IME_GETVERSION = $07;
  180. {$EXTERNALSYM IME_GETVERSION}
  181. IME_SETCONVERSIONWINDOW = $08;
  182. {$EXTERNALSYM IME_SETCONVERSIONWINDOW}
  183. IME_MOVEIMEWINDOW = IME_SETCONVERSIONWINDOW; // KOREA only
  184. {$EXTERNALSYM IME_MOVEIMEWINDOW}
  185. IME_SETCONVERSIONMODE = $10;
  186. {$EXTERNALSYM IME_SETCONVERSIONMODE}
  187. IME_GETCONVERSIONMODE = $11;
  188. {$EXTERNALSYM IME_GETCONVERSIONMODE}
  189. IME_SET_MODE = $12; // KOREA only
  190. {$EXTERNALSYM IME_SET_MODE}
  191. IME_SENDVKEY = $13;
  192. {$EXTERNALSYM IME_SENDVKEY}
  193. IME_ENTERWORDREGISTERMODE = $18;
  194. {$EXTERNALSYM IME_ENTERWORDREGISTERMODE}
  195. IME_SETCONVERSIONFONTEX = $19;
  196. {$EXTERNALSYM IME_SETCONVERSIONFONTEX}
  197. //
  198. // IME_CODECONVERT subfunctions
  199. //
  200. IME_BANJAtoJUNJA = $13; // KOREA only
  201. {$EXTERNALSYM IME_BANJAtoJUNJA}
  202. IME_JUNJAtoBANJA = $14; // KOREA only
  203. {$EXTERNALSYM IME_JUNJAtoBANJA}
  204. IME_JOHABtoKS = $15; // KOREA only
  205. {$EXTERNALSYM IME_JOHABtoKS}
  206. IME_KStoJOHAB = $16; // KOREA only
  207. {$EXTERNALSYM IME_KStoJOHAB}
  208. //
  209. // IME_AUTOMATA subfunctions
  210. //
  211. IMEA_INIT = $01; // KOREA only
  212. {$EXTERNALSYM IMEA_INIT}
  213. IMEA_NEXT = $02; // KOREA only
  214. {$EXTERNALSYM IMEA_NEXT}
  215. IMEA_PREV = $03; // KOREA only
  216. {$EXTERNALSYM IMEA_PREV}
  217. //
  218. // IME_HANJAMODE subfunctions
  219. //
  220. IME_REQUEST_CONVERT = $01; // KOREA only
  221. {$EXTERNALSYM IME_REQUEST_CONVERT}
  222. IME_ENABLE_CONVERT = $02; // KOREA only
  223. {$EXTERNALSYM IME_ENABLE_CONVERT}
  224. //
  225. // IME_MOVEIMEWINDOW subfunctions
  226. //
  227. INTERIM_WINDOW = $00; // KOREA only
  228. {$EXTERNALSYM INTERIM_WINDOW}
  229. MODE_WINDOW = $01; // KOREA only
  230. {$EXTERNALSYM MODE_WINDOW}
  231. HANJA_WINDOW = $02; // KOREA only
  232. {$EXTERNALSYM HANJA_WINDOW}
  233. //
  234. // error code
  235. //
  236. IME_RS_ERROR = $01; // genetal error
  237. {$EXTERNALSYM IME_RS_ERROR}
  238. IME_RS_NOIME = $02; // IME is not installed
  239. {$EXTERNALSYM IME_RS_NOIME}
  240. IME_RS_TOOLONG = $05; // given string is too long
  241. {$EXTERNALSYM IME_RS_TOOLONG}
  242. IME_RS_ILLEGAL = $06; // illegal charactor(s) is string
  243. {$EXTERNALSYM IME_RS_ILLEGAL}
  244. IME_RS_NOTFOUND = $07; // no (more) candidate
  245. {$EXTERNALSYM IME_RS_NOTFOUND}
  246. IME_RS_NOROOM = $0a; // no disk/memory space
  247. {$EXTERNALSYM IME_RS_NOROOM}
  248. IME_RS_DISKERROR = $0e; // disk I/O error
  249. {$EXTERNALSYM IME_RS_DISKERROR}
  250. IME_RS_INVALID = $11; // Win3.1/NT
  251. {$EXTERNALSYM IME_RS_INVALID}
  252. IME_RS_NEST = $12; // called nested
  253. {$EXTERNALSYM IME_RS_NEST}
  254. IME_RS_SYSTEMMODAL = $13; // called when system mode
  255. {$EXTERNALSYM IME_RS_SYSTEMMODAL}
  256. //
  257. // report messge from IME to WinApps
  258. //
  259. WM_IME_REPORT = $0280;
  260. {$EXTERNALSYM WM_IME_REPORT}
  261. //
  262. // report message parameter for WM_IME_REPORT
  263. //
  264. IR_STRINGSTART = $100;
  265. {$EXTERNALSYM IR_STRINGSTART}
  266. IR_STRINGEND = $101;
  267. {$EXTERNALSYM IR_STRINGEND}
  268. IR_OPENCONVERT = $120;
  269. {$EXTERNALSYM IR_OPENCONVERT}
  270. IR_CHANGECONVERT = $121;
  271. {$EXTERNALSYM IR_CHANGECONVERT}
  272. IR_CLOSECONVERT = $122;
  273. {$EXTERNALSYM IR_CLOSECONVERT}
  274. IR_FULLCONVERT = $123;
  275. {$EXTERNALSYM IR_FULLCONVERT}
  276. IR_IMESELECT = $130;
  277. {$EXTERNALSYM IR_IMESELECT}
  278. IR_STRING = $140;
  279. {$EXTERNALSYM IR_STRING}
  280. IR_DBCSCHAR = $160;
  281. {$EXTERNALSYM IR_DBCSCHAR}
  282. IR_UNDETERMINE = $170;
  283. {$EXTERNALSYM IR_UNDETERMINE}
  284. IR_STRINGEX = $180; // New for 3.1
  285. {$EXTERNALSYM IR_STRINGEX}
  286. IR_MODEINFO = $190;
  287. {$EXTERNALSYM IR_MODEINFO}
  288. //#define WM_CONVERTREQUESTEX 0x0109
  289. WM_WNT_CONVERTREQUESTEX = $0109; // WM_CONVERTREQUESTEX: 109 for NT, 108 for OT
  290. {$EXTERNALSYM WM_WNT_CONVERTREQUESTEX}
  291. WM_CONVERTREQUEST = $010A;
  292. {$EXTERNALSYM WM_CONVERTREQUEST}
  293. WM_CONVERTRESULT = $010B;
  294. {$EXTERNALSYM WM_CONVERTRESULT}
  295. WM_INTERIM = $010C;
  296. {$EXTERNALSYM WM_INTERIM}
  297. WM_IMEKEYDOWN = $290;
  298. {$EXTERNALSYM WM_IMEKEYDOWN}
  299. WM_IMEKEYUP = $291;
  300. {$EXTERNALSYM WM_IMEKEYUP}
  301. //
  302. // UNDETERMINESTRING structure for IR_UNDETERMINE
  303. //
  304. type
  305. tagUNDETERMINESTRUCT = record
  306. dwSize: DWORD;
  307. uDefIMESize: UINT;
  308. uDefIMEPos: UINT;
  309. uUndetTextLen: UINT;
  310. uUndetTextPos: UINT;
  311. uUndetAttrPos: UINT;
  312. uCursorPos: UINT;
  313. uDeltaStart: UINT;
  314. uDetermineTextLen: UINT;
  315. uDetermineTextPos: UINT;
  316. uDetermineDelimPos: UINT;
  317. uYomiTextLen: UINT;
  318. uYomiTextPos: UINT;
  319. uYomiDelimPos: UINT;
  320. end;
  321. {$EXTERNALSYM tagUNDETERMINESTRUCT}
  322. UNDETERMINESTRUCT = tagUNDETERMINESTRUCT;
  323. {$EXTERNALSYM UNDETERMINESTRUCT}
  324. LPUNDETERMINESTRUCT = ^UNDETERMINESTRUCT;
  325. {$EXTERNALSYM LPUNDETERMINESTRUCT}
  326. PUNDETERMINESTRUCT = ^UNDETERMINESTRUCT;
  327. {$EXTERNALSYM PUNDETERMINESTRUCT}
  328. NPUNDETERMINESTRUCT = ^UNDETERMINESTRUCT;
  329. {$EXTERNALSYM NPUNDETERMINESTRUCT}
  330. TUndetermineStruct = UNDETERMINESTRUCT;
  331. tagSTRINGEXSTRUCT = record
  332. dwSize: DWORD;
  333. uDeterminePos: UINT;
  334. uDetermineDelimPos: UINT;
  335. uYomiPos: UINT;
  336. uYomiDelimPos: UINT;
  337. end;
  338. {$EXTERNALSYM tagSTRINGEXSTRUCT}
  339. STRINGEXSTRUCT = tagSTRINGEXSTRUCT;
  340. {$EXTERNALSYM STRINGEXSTRUCT}
  341. LPSTRINGEXSTRUCT = ^STRINGEXSTRUCT;
  342. {$EXTERNALSYM LPSTRINGEXSTRUCT}
  343. PSTRINGEXSTRUCT = ^STRINGEXSTRUCT;
  344. {$EXTERNALSYM PSTRINGEXSTRUCT}
  345. NPSTRINGEXSTRUCT = ^STRINGEXSTRUCT;
  346. {$EXTERNALSYM NPSTRINGEXSTRUCT}
  347. TStringexStruct = STRINGEXSTRUCT;
  348. implementation
  349. const
  350. imelib = 'user32.dll';
  351. {$IFDEF UNICODE}
  352. AWSuffix = 'W';
  353. {$ELSE}
  354. AWSuffix = 'A';
  355. {$ENDIF UNICODE}
  356. {$IFDEF DYNAMIC_LINK}
  357. var
  358. _SendIMEMessageExA: Pointer;
  359. function SendIMEMessageExA;
  360. begin
  361. GetProcedureAddress(_SendIMEMessageExA, imelib, 'SendIMEMessageExA');
  362. asm
  363. MOV ESP, EBP
  364. POP EBP
  365. JMP [_SendIMEMessageExA]
  366. end;
  367. end;
  368. var
  369. _SendIMEMessageExW: Pointer;
  370. function SendIMEMessageExW;
  371. begin
  372. GetProcedureAddress(_SendIMEMessageExW, imelib, 'SendIMEMessageExW');
  373. asm
  374. MOV ESP, EBP
  375. POP EBP
  376. JMP [_SendIMEMessageExW]
  377. end;
  378. end;
  379. var
  380. _SendIMEMessageEx: Pointer;
  381. function SendIMEMessageEx;
  382. begin
  383. GetProcedureAddress(_SendIMEMessageEx, imelib, 'SendIMEMessageEx' + AWSuffix);
  384. asm
  385. MOV ESP, EBP
  386. POP EBP
  387. JMP [_SendIMEMessageEx]
  388. end;
  389. end;
  390. {$ELSE}
  391. function SendIMEMessageExA; external imelib name 'SendIMEMessageExA';
  392. function SendIMEMessageExW; external imelib name 'SendIMEMessageExW';
  393. function SendIMEMessageEx; external imelib name 'SendIMEMessageEx' + AWSuffix;
  394. {$ENDIF DYNAMIC_LINK}
  395. end.