⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msime.pas

📁 这篇文档是讲如何利用IFELanguage接口实现对中文语句的分隔
💻 PAS
📖 第 1 页 / 共 3 页
字号:
    function GetHeader(
      pchDictPath: PChar; //(in) dictionary path
      pshf: PIMESHF; //(out) dictionary header
      pjfmt: PIMEFMT; //(out) dictionary format
      pulType: PDWORD //(out) dictionary type
    ): HResult; stdcall;
    function DisplayProperty(
      hwnd: HWND //(in) parent window handle
    ): HResult; stdcall;
    function GetPosTable(
      prgPosTbl: PPOSTBL; //(out) pos table pointer
      pcPosTbl: PInteger //(out) pos table count pointer
    ): HResult; stdcall;
    function GetWords(
      pwchFirst: PWideChar; //(in) starting range of reading
      pwchLast: PWideChar; //(in) ending range of reading
      pwchDisplay: PWideChar; //(in) display
      ulPos: ULONG; //(in) part of speech (IFED_POS_...)
      ulSelect: ULONG; //(in) output selection
      ulWordSrc: ULONG; //(in) user or auto registered word?
      pchBuffer: PByte; //(in/out) buffer for storing array of IMEWRD
      cbBuffer: ULONG; //(in) size of buffer in bytes
      pcWrd: PULONG //(out) count of IMEWRD's returned
    ): HResult; stdcall;
    function NextWords(
      pchBuffer: PByte; //(in/out) buffer for storing array of IMEWRD
      cbBuffer: ULONG; //(in) size of buffer in bytes
      pcWrd: PULONG //(out) count of IMEWRD's returned
    ): HResult; stdcall;
    function Create(
      pchDictPath: PChar; //(in) path for the new dictionary
      pshf: PIMESHF //(in) dictionary header
    ): HResult; stdcall;
    function SetHeader(
      pshf: PIMESHF //(in) dictionary header
    ): HResult; stdcall;
    function ExistWord(
      pwrd: PIMEWRD //(in) word to check
    ): HResult; stdcall;
    function Reserved1(
      pv: Pointer
    ): HResult; stdcall;
    function RegisterWord(
      reg: IMEREG; //(in) type of operation to perform on IMEWRD
      pwrd: PIMEWRD //(in) word to be registered or deleted
    ): HResult; stdcall;
  end;

///////////////////////////////////
// Definitions for PerIME Interface
///////////////////////////////////

//***********************************************************************
//    IME Version IDs
//***********************************************************************
const
  VERSION_ID_JAPANESE = $01000000;
  VERSION_ID_KOREAN = $02000000;
  VERSION_ID_CHINESE_TRADITIONAL = $04000000;
  VERSION_ID_CHINESE_SIMPLIFIED = $08000000;

  VERSION_ID_IMEJP98 = VERSION_ID_JAPANESE or $980;
  VERSION_ID_IMEJP2000 = VERSION_ID_JAPANESE or $98A;

//***********************************************************************
//    Msg:    WM_MSIME_SERVICE
//    Desc:   service functions
//    Dir:    Apps to IME
//    wParam: reserved
//    lParam: reserved
//***********************************************************************/

// Label for RegisterWindowMessage
  RWM_SERVICE = 'MSIMEService';

//getting version number (wParam)
  FID_MSIME_VERSION = 0;

//***********************************************************************
//    Msg:    WM_MSIME_UIREADY
//    Desc:   service functions
//    Dir:    IME to Apps
//    wParam: Version ID
//    lParam: reserved
//***********************************************************************/

// Label for RegisterWindowMessage
  RWM_UIREADY = 'MSIMEUIReady';



//***********************************************************************
//    Msg:    WM_MSIME_MOUSE
//    Desc:   mouse operation definition
//    Dir:    Apps to IME
//***********************************************************************/

// Label for RegisterWindowMessage
  RWM_MOUSE = 'MSIMEMouseOperation';

// Mouse Operation Version (return value of IMEMOUSE_VERSION)
  VERSION_MOUSE_OPERATION = 1;

// Mouse operation result
  IMEMOUSERET_NOTHANDLED = -1;

//WParam definition for WM_IME_MOUSE.
  IMEMOUSE_VERSION = $ff;    // mouse supported?

  IMEMOUSE_NONE = $00;    // no mouse button was pushed
  IMEMOUSE_LDOWN = $01;
  IMEMOUSE_RDOWN = $02;
  IMEMOUSE_MDOWN = $04;
  IMEMOUSE_WUP = $10;    // wheel up
  IMEMOUSE_WDOWN = $20;    // wheel down


//***********************************************************************
//    Msg:    WM_MSIME_RECONVERT
//    Desc:   reconversion
//    Dir:    IME to Apps
//***********************************************************************/

// Label for RegisterWindowMessage
  RWM_RECONVERT = 'MSIMEReconvert';


//***********************************************************************
//    Msg:    WM_MSIME_RECONVERTREQUEST
//    Desc:   reconversion
//    Dir:    Apps to IME
//***********************************************************************/

// wParam of WM_MSIME_RECONVERTREQUEST
  FID_RECONVERT_VERSION = $10000000;

// Private reconversion Version
  VERSION_RECONVERSION = 1;

// Label for RegisterWindowMessage
  RWM_RECONVERTREQUEST = 'MSIMEReconvertRequest';


//***********************************************************************
//    Msg:    WM_MSIME_DOCUMENTFEED
//    Desc:   Document feeding
//    Dir:    IME to Apps
//    Usage:  SendMessage( hwndApp, WM_MSIME_DOCUMENTFEED, VERSION_DOCUMENTFEED,
//                (RECONVERTSTRING*)pReconv );
//    wParam: VERSION_DOCUMENTFEED
//    lParam: Pointer of RECONVERTSTRING structure
//    return: size of RECONVERTSTRING structure
//***********************************************************************/

// wParam of WM_MSIME_DOCUMENTFEED (set current docfeed version)
  VERSION_DOCUMENTFEED = 1;

// lParam is pointer of RECONVERTSTRING structure

// Label for RegisterWindowMessage
  RWM_DOCUMENTFEED = 'MSIMEDocumentFeed';

//***********************************************************************
//    Msg:    WM_MSIME_QUERYPOSITION
//    Desc:   composition UI
//    Dir:    IME to Apps
//    Usage:  SendMessage( hwndApp, WM_MSIME_QUERYPOSITION, VERSION_QUERYPOSITION, (IMEPOSITION*)pPs );
//    wParam: reserved. must be 0.
//    lParam: pointer of IMEPOSITION structure
//    return: Non-zero = success. Zero = error.
//***********************************************************************/

// wParam of WM_MSIME_QUERYPOSITION
  VERSION_QUERYPOSITION = 1;

// Label for RegisterWindowMessage
  RWM_QUERYPOSITION = 'MSIMEQueryPosition';


//***********************************************************************
//    Msg:    WM_MSIME_MODEBIAS
//    Desc:   input mode bias
//    Dir:    Apps to IME
//    Usage:  SendMessage( hwndDefUI, WM_MSIME_MODEBIAS, MODEBIAS_xxxx, MODEBIASMODE_xxxx );
//    wParam: operation of bias
//    lParam: bias mode
//    return: If wParam is MODEBIAS_GETVERSION,returns version number of interface.
//            If wParam is MODEBIAS_SETVALUE : return non-zero value if succeeded. Returns 0 if fail.
//            If wParam is MODEBIAS_GETVALUE : returns current bias mode.
//***********************************************************************/

// Label for RegisterWindowMessage
  RWM_MODEBIAS = 'MSIMEModeBias';

// Current version
  VERSION_MODEBIAS = 1;

// Set or Get (wParam)
  MODEBIAS_GETVERSION = 0;
  MODEBIAS_SETVALUE = 1;
  MODEBIAS_GETVALUE = 2;

// Bias (lParam)
  MODEBIASMODE_DEFAULT = $00000000; // reset all of bias setting
  MODEBIASMODE_FILENAME = $00000001; // filename


//***********************************************************************
//    Msg:    WM_MSIME_SHOWIMEPAD
//    Desc:   show ImePad
//    Usage: SendMessage( hwndDefUI, WM_MSIME_SHOWIMEPAD, wParam, lParam );
//    wParam: Applet selection option
//    lParam: Applet selection parameter
//            (Category defined in imepad.h or a pointer to GUID for Applet)
//    return: Non-zero = accepted. Zero = not accepted.
//***********************************************************************/

// Label for RegisterWindowMessage
  RWM_SHOWIMEPAD = 'MSIMEShowImePad';

// Applet selection option
  SHOWIMEPAD_DEFAULT = $00000000;  // default applet
  SHOWIMEPAD_CATEGORY = $00000001;  // selection by applet category
  SHOWIMEPAD_GUID = $00000002;  // selection by applet GUID


//***********************************************************************
//    Msg:    WM_MSIME_KEYMAP
//    Desc:   key map sharing with apps
//***********************************************************************/

// Label for RegisterWindowMessage
  RWM_KEYMAP = 'MSIMEKeyMap';
  RWM_CHGKEYMAP = 'MSIMEChangeKeyMap';
  RWM_NTFYKEYMAP = 'MSIMENotifyKeyMap';

  FID_MSIME_KMS_VERSION = 1;
  FID_MSIME_KMS_INIT = 2;
  FID_MSIME_KMS_TERM = 3;
  FID_MSIME_KMS_DEL_KEYLIST = 4;
  FID_MSIME_KMS_NOTIFY = 5;
  FID_MSIME_KMS_GETMAP = 6;
  FID_MSIME_KMS_INVOKE = 7;
  FID_MSIME_KMS_SETMAP = 8;

  IMEKMS_NOCOMPOSITION = 0;
  IMEKMS_COMPOSITION = 1;
  IMEKMS_SELECTION = 2;
  IMEKMS_IMEOFF = 3;
  IMEKMS_2NDLEVEL = 4; // Reserved
  IMEKMS_INPTGL = 5; // Reserved
  IMEKMS_CANDIDATE = 6; // Reserved
  IMEKMS_TYPECAND = 7; // Reserved


type
  tagIMEKMSINIT = packed record
    cbSize: Integer;
    hWnd: HWND; // Window which receives notification from IME.
                // If hWnd is NULL, no notification is posted
                // to Input context.
  end;
  IMEKMSINIT = tagIMEKMSINIT;
  PIMEKMSINIT = ^IMEKMSINIT;

  tagIMEKMSKEY = packed record
    dwStatus: DWORD; //Shift-Control combination status.
                     //Any combination of constants below
                     //(defined in IMM.H)
                     // $0000 (default)
                     // MOD_CONTROL     $0002
                     // MOD_SHIFT       $0004
                     // Alt key and Win key is not processed by IME.

    dwCompStatus: DWORD; //Composition string status
                         //One of the constants below
                         // IMEKMS_NOCOMPOSITION  No composition string
                         // IMEKMS_COMPOSITION    Some composition string
                         // IMEKMS_SELECTION      Selection exists in apps
                         // IMEKMS_IMEOFF         IME Off state


    dwVKEY: DWORD; // VKEY code defined in IMM.H
    dwControl: DWORD; // IME Functionality ID
        //dwNotUsed: DWORD;
    pwszDscr: array[0..31 - 1]of WideChar; // The pointer to string of description of this functionalify
        //pwszNoUse: array[0..31 - 1]of WideChar;
  end;
  IMEKMSKEY = tagIMEKMSKEY;
  PIMEKMSKEY = ^IMEKMSKEY;
  tagIMEKMS = packed record
    cbSize: Integer;
    hIMC: HIMC;
    cKeyList: DWORD;
    pKeyList: PIMEKMSKEY;
  end;

  tagIMEKMSNTFY = packed record
    cbSize: Integer;
    hIMC: HIMC;
    fSelect: BOOL;
  end;
  IMEKMSNTFY = tagIMEKMSNTFY;

  tagIMEKMSKMP = packed record
    cbSize: Integer; //[in] size of this structure
    hIMC: HIMC; //[in] Input context
    idLang: LANGID; //[in] Language ID
    wVKStart: WORD; //[in] VKEY start
    wVKEnd: WORD; //[in] VKEY end
    cKeyList: Integer; //[out] number of IMEKMSKEY
    pKeyList: PIMEKMSKEY; //[out] retrieve buffer of IMEKMSKEY
                          //      Must be GlobalMemFree by clients
  end;
  IMEKMSKMP = tagIMEKMSKMP;

  tagIMEKMSINVK = packed record
    cbSize: Integer;
    hIMC: HIMC;
    dwControl: DWORD;
  end;
  IMEKMSINVK = tagIMEKMSINVK;

//***********************************************************************
//    Msg:    WM_MSIME_RECONVERTOPTIONS
//    Desc:   Set reconversion options
//    Usage: SendMessage( hwndDefUI, WM_MSIME_RECONVERTOPTIONS, dwOpt, (LPARAM)(HIMC)hIMC );
//    wParam: options
//    lParam: Input context handle
//    return: Non-zero = accepted. Zero = not accepted.
//***********************************************************************/

// Label for RegisterWindowMessage
const
  RWM_RECONVERTOPTIONS = 'MSIMEReconvertOptions';

//WParam definition for WM_IME_RECONVERTOPTIONS.
  RECONVOPT_NONE = $00000000;  // default
  RECONVOPT_USECANCELNOTIFY = $00000001;  // cancel notify

// parameter of ImmGetCompositionString
  GCSEX_CANCELRECONVERT = $10000000;

type
// The following API replaces CoCreateInstance(), when CLSID is not used.
//HRESULT WINAPI CreateIFECommonInstance(VOID **ppvObj);
//typedef HRESULT (WINAPI *fpCreateIFECommonInstanceType)(VOID **ppvObj);
  fpCreateIFECommonInstanceType = function(out ppvObj): HRESULT; stdcall;

// The IFELanguage global export function
//HRESULT WINAPI CreateIFELanguageInstance(REFCLSID clsid, VOID **ppvObj);
//typedef HRESULT (WINAPI *fpCreateIFELanguageInstanceType)(REFCLSID clsid, VOID **ppvObj);
  fpCreateIFELanguageInstanceType = function(clsid: TGUID; out ppvObj): HRESULT; stdcall;

// The following API replaces CoCreateInstance(), when CLSID is not used.
//HRESULT WINAPI CreateIFEDictionaryInstance(VOID **ppvObj);
//typedef HRESULT (WINAPI *fpCreateIFEDictionaryInstanceType)(VOID **ppvObj);
  fpCreateIFEDictionaryInstanceType = function(out ppvObj): HRESULT; stdcall;

implementation

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -