June 24, 2005

How to get IME settings such as converted text color

Windows IME (Input Method Editor) has some mode to use Imm API.

  • Half-aware
  • Full-aware

Half-aware mode

By handling a few windows message, you can use inline-input of IME string. And, IME will handle about rendering.

Full-aware mode

By handling many windows message, you can use inline-input of IME string. Since IME doesn't handle about rendering and application must render strings...

Some application uses full-aware mode (ex. Microsoft Office, FireFox). Although Active IMM support on Mozilla/FireFox is written by me, many enhanced functions of IME are implemented by me too. Although Redering code is implemented by Frank Tang who was Netscape Engineer, there is a important problem about this code.

  • It uses hard-corded value for IME color. If we want to change it, we cannot do it

How can we get this color from IME? We should use sepecfic API each IMEs. Microsoft and Just System (known as ATOK) provide a document how to use configuration shared library.

Microsoft (MSIME)
http://msdn.microsoft.com/library/en-us/dnime/html/imeshare.asp
Just System (ATOK)
http://www.justsystem.co.jp/tech/atok/amet12_00.html

Unfortunatelly, this document of MSIME is useless. Because, although this document explains hwo to use IMESHARE.DLL API, there is no header file into SDK. Sit MS! So I have reseached how to use IMESHARE API.

header may be this...

class CIMEShare
{
public:
    virtual void __cdecl CustomizeIMEShare();
    virtual BOOL __cdecl FSupportSty(UINT, UINT);
    virtual LID __cdecl LidSetLid(LID);
    virtual LID __cdecl LidGetLid();
    virtual DWORD __cdecl DwGetIMEStyle(const UINT, const UINT);
    virtual BOOL __cdecl FDeleteIMEShare();
    virtual BOOL __cdecl DwGetIMEStyleCpl(const UINT, const UINT);
    virtual BOOL __cdecl FSetIMEStyleCpl(const UINT, const UINT, DWORD);
    virtual BOOL __cdecl FSaveIMEShareCpl();
};

typedef CIMEShare * (WINAPI *PIMESHARECREATE) (void);

#define IMESATTR_INPUT 1
#define IMESATTR_TARGET_CONVERTED 2
#define IMESATTR_CONVERTED 3
#define IMESATTR_TARGET_NOTCONVERTED 4

#define IdstyIMEShareSubText 0
#define IdstyIMEShareSubBack 1
#define IdstyIMEShareSubUl 2
#define IdstyIMEShareFBold 0x100
#define IdstyIMEShareFItalic 0x200
#define IdstyIMEShareFUl 0x300
#define IdstyIMEShareUKul 0x400
#define IdstyIMEShareFWinCol 0x500
#define IdstyIMEShareFFundCol 0x600
#define IdstyIMEShareFRGBCol 0x700
#define IdstyIMEShareFSpecCol 0x800
#define IdstyIMEShareRGBCol 0x900

#define IMESTY_UL_NONE 0x7d2
#define IMESTY_UL_SINGLE (IMESTY_UL_NONE + 1)
#define IMESTY_UL_DOTTED (IMESTY_UL_NONE + 3)

How to use IMESHARE API.

hImeShare = LoadLibrary(_T("IMESHARE.DLL"));
if (hImeShare)
{
  pfnImeShareCreate = (PIMESHARECREATE) GetProcAddress(hImeShare, "PIMEShareCreate");
  if (pfnImeShareCreate)
  {
    CIMEShare *pIMEShare = pfnImeShareCreate();
    if (pIMEShare)
    {
      DWORD dwColor = pIMEShare->DwGetIMEStyle(IMESATTR_INPUT, IdstyIMEShareSubText | IdstyIMEShareRGBCol);

      ....

      pIMEShare->FDeleteIMEShare();
    }
  }
  FreeLibrary(hImeShare);
}

Of cource, I have a patch for Firefox 1.1. But coming soon...

Trackback URL: http://www.mozilla-x86-64.com/mt/mt-tb.cgi/56