jwaime.pas 13 KB

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