' ########################################################################################
' Microsoft Windows
' File: Ime.inc
' Contents: Procedure declarations, constant definitions and macros for the IME component
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_Ime_PBI)
#DEFINE PBX_Ime_PBI
%EQUATE `IME_INC = 1
'#ifndef _WINDEF_
'typedef unsigned int UINT;
'#endif // _WINDEF_
%EQUATE `IME_MAXPROCESS = 32
DECLARE FUNCTION SendIMEMessageEx LIB "imm32.dll" ALIAS "SendIMEMessageExA" ( BYVAL hWnd AS QUAD , BYVAL lParam AS LONG ) AS LONG ' LRESULT
DECLARE FUNCTION SendIMEMessageExW LIB "imm32.dll" ALIAS "SendIMEMessageExW" ( BYVAL hWnd AS QUAD , BYVAL lParam AS LONG ) AS LONG ' LRESULT
'//
'// IMESTRUCT structure for SendIMEMessageEx
'//
' // Size = 32 bytes
TYPE IMESTRUCT DWORD
 fnc AS DWORD ' UINT fnc // function code
 wParam AS LONG ' WPARAM wParam // word parameter
 wCount AS DWORD ' UINT wCount // word counter
 dchSource AS DWORD ' UINT dchSource // offset to Source from top of memory object
 dchDest AS DWORD ' UINT dchDest // offset to Desrination from top of memory object
 lParam1 AS LONG ' LPARAM lParam1
 lParam2 AS LONG ' LPARAM lParam2
 lParam3 AS LONG ' LPARAM lParam3
END TYPE
%EQUATE `CP_HWND = 0
%EQUATE `CP_OPEN = 1
%EQUATE `CP_DIRECT = 2
%EQUATE `CP_LEVEL = 3
'//
'// Virtual Keys
'//
#IF NOT %DEF(%VK_DBE_ALPHANUMERIC)
%EQUATE `VK_DBE_ALPHANUMERIC = &H0f0
%EQUATE `VK_DBE_KATAKANA = &H0f1
%EQUATE `VK_DBE_HIRAGANA = &H0f2
%EQUATE `VK_DBE_SBCSCHAR = &H0f3
%EQUATE `VK_DBE_DBCSCHAR = &H0f4
%EQUATE `VK_DBE_ROMAN = &H0f5
%EQUATE `VK_DBE_NOROMAN = &H0f6
%EQUATE `VK_DBE_ENTERWORDREGISTERMODE = &H0f7
%EQUATE `VK_DBE_ENTERIMECONFIGMODE = &H0f8
%EQUATE `VK_DBE_FLUSHSTRING = &H0f9
%EQUATE `VK_DBE_CODEINPUT = &H0fa
%EQUATE `VK_DBE_NOCODEINPUT = &H0fb
%EQUATE `VK_DBE_DETERMINESTRING = &H0fc
%EQUATE `VK_DBE_ENTERDLGCONVERSIONMODE = &H0fd
#ENDIF
'//
'// switch for wParam of IME_SETCONVERSIONWINDOW
'//
%EQUATE `MCW_DEFAULT = &H00
%EQUATE `MCW_RECT = &H01
%EQUATE `MCW_WINDOW = &H02
%EQUATE `MCW_SCREEN = &H04
%EQUATE `MCW_VERTICAL = &H08
%EQUATE `MCW_HIDDEN = &H10
'//
'// switch for wParam of IME_SETCONVERSIONMODE
'// and IME_GETCONVERSIONMODE
'//
%EQUATE `IME_MODE_ALPHANUMERIC = &H0001
#IF %DEF(%KOREA) ' BeomOh - 9/29/92
 %IME_MODE_SBCSCHAR = &H0002
#ELSE
 %IME_MODE_SBCSCHAR = &H0008
#ENDIF
%EQUATE `IME_MODE_KATAKANA = &H0002
%EQUATE `IME_MODE_HIRAGANA = &H0004
%EQUATE `IME_MODE_HANJACONVERT = &H0004
%EQUATE `IME_MODE_DBCSCHAR = &H0010
%EQUATE `IME_MODE_ROMAN = &H0020
%EQUATE `IME_MODE_NOROMAN = &H0040
%EQUATE `IME_MODE_CODEINPUT = &H0080
%EQUATE `IME_MODE_NOCODEINPUT = &H0100
'//
'// IME APIs
'//
%EQUATE `IME_GETIMECAPS = &H03
%EQUATE `IME_SETOPEN = &H04
%EQUATE `IME_GETOPEN = &H05
%EQUATE `IME_GETVERSION = &H07
%EQUATE `IME_SETCONVERSIONWINDOW = &H08
%EQUATE `IME_MOVEIMEWINDOW = %IME_SETCONVERSIONWINDOW ' KOREA only
%EQUATE `IME_SETCONVERSIONMODE = &H10
%EQUATE `IME_GETCONVERSIONMODE = &H11
%EQUATE `IME_SET_MODE = &H12 ' KOREA only
%EQUATE `IME_SENDVKEY = &H13
%EQUATE `IME_ENTERWORDREGISTERMODE = &H18
%EQUATE `IME_SETCONVERSIONFONTEX = &H19
'//
'// IME_CODECONVERT subfunctions
'//
%EQUATE `IME_BANJAtoJUNJA = &H13 ' KOREA only
%EQUATE `IME_JUNJAtoBANJA = &H14 ' KOREA only
%EQUATE `IME_JOHABtoKS = &H15 ' KOREA only
%EQUATE `IME_KStoJOHAB = &H16 ' KOREA only
'//
'// IME_AUTOMATA subfunctions
'//
%EQUATE `IMEA_INIT = &H01 ' KOREA only
%EQUATE `IMEA_NEXT = &H02 ' KOREA only
%EQUATE `IMEA_PREV = &H03 ' KOREA only
'//
'// IME_HANJAMODE subfunctions
'//
%EQUATE `IME_REQUEST_CONVERT = &H01 ' KOREA only
%EQUATE `IME_ENABLE_CONVERT = &H02 ' KOREA only
'//
'// IME_MOVEIMEWINDOW subfunctions
'//
%EQUATE `INTERIM_WINDOW = &H00 ' KOREA only
%EQUATE `MODE_WINDOW = &H01 ' KOREA only
%EQUATE `HANJA_WINDOW = &H02 ' KOREA only
'//
'// error code
'//
%EQUATE `IME_RS_ERROR = &H01 ' genetal error
%EQUATE `IME_RS_NOIME = &H02 ' IME is not installed
%EQUATE `IME_RS_TOOLONG = &H05 ' given string is too long
%EQUATE `IME_RS_ILLEGAL = &H06 ' illegal charactor(s) is string
%EQUATE `IME_RS_NOTFOUND = &H07 ' no (more) candidate
%EQUATE `IME_RS_NOROOM = &H0a ' no disk/memory space
%EQUATE `IME_RS_DISKERROR = &H0e ' disk I/O error
%EQUATE `IME_RS_INVALID = &H11 ' Win3.1/NT
%EQUATE `IME_RS_NEST = &H12 ' called nested
%EQUATE `IME_RS_SYSTEMMODAL = &H13 ' called when system mode
'//
'// report messge from IME to WinApps
'//
%EQUATE `WM_IME_REPORT = &H0280
'//
'// report message parameter for WM_IME_REPORT
'//
%EQUATE `IR_STRINGSTART = &H100
%EQUATE `IR_STRINGEND = &H101
%EQUATE `IR_OPENCONVERT = &H120
%EQUATE `IR_CHANGECONVERT = &H121
%EQUATE `IR_CLOSECONVERT = &H122
%EQUATE `IR_FULLCONVERT = &H123
%EQUATE `IR_IMESELECT = &H130
%EQUATE `IR_STRING = &H140
%EQUATE `IR_DBCSCHAR = &H160
%EQUATE `IR_UNDETERMINE = &H170
%EQUATE `IR_STRINGEX = &H180 ' New for 3.1
%EQUATE `IR_MODEINFO = &H190
'//#define WM_CONVERTREQUESTEX 0x0109
%EQUATE `WM_WNT_CONVERTREQUESTEX = &H0109 ' %WM_CONVERTREQUESTEX: 109 for NT, 108 for OT
%EQUATE `WM_CONVERTREQUEST = &H010A
%EQUATE `WM_CONVERTRESULT = &H010B
%EQUATE `WM_INTERIM = &H010C
%EQUATE `WM_IMEKEYDOWN = &H290
%EQUATE `WM_IMEKEYUP = &H291
'//
'// UNDETERMINESTRING structure for IR_UNDETERMINE
'//
' // Size = 56 bytes
TYPE UNDETERMINESTRUCT DWORD
 dwSize AS DWORD ' DWORD dwSize
 uDefIMESize AS DWORD ' UINT uDefIMESize
 uDefIMEPos AS DWORD ' UINT uDefIMEPos
 uUndetTextLen AS DWORD ' UINT uUndetTextLen
 uUndetTextPos AS DWORD ' UINT uUndetTextPos
 uUndetAttrPos AS DWORD ' UINT uUndetAttrPos
 uCursorPos AS DWORD ' UINT uCursorPos
 uDeltaStart AS DWORD ' UINT uDeltaStart
 uDetermineTextLen AS DWORD ' UINT uDetermineTextLen
 uDetermineTextPos AS DWORD ' UINT uDetermineTextPos
 uDetermineDelimPos AS DWORD ' UINT uDetermineDelimPos
 uYomiTextLen AS DWORD ' UINT uYomiTextLen
 uYomiTextPos AS DWORD ' UINT uYomiTextPos
 uYomiDelimPos AS DWORD ' UINT uYomiDelimPos
END TYPE
' // Size = 20 bytes
TYPE STRINGEXSTRUCT DWORD
 dwSize AS DWORD ' DWORD dwSize
 uDeterminePos AS DWORD ' UINT uDeterminePos
 uDetermineDelimPos AS DWORD ' UINT uDetermineDelimPos
 uYomiPos AS DWORD ' UINT uYomiPos
 uYomiDelimPos AS DWORD ' UINT uYomiDelimPos
END TYPE
#ENDIF
