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

📄 tsf.cpp

📁 手机上的韩文输入法 saenaru20031212.zip
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* imported from the skkime by wkpark */
#if !defined (NO_TSF)
#include "windows.h"
#include "tchar.h"
#include "immdev.h"
extern "C" {
#include "saenaru.h"
#include "resource.h"
}
#include "c:\Program Files\Microsoft SDK\include\msctf.h"
#include "c:\Program Files\Microsoft SDK\include\olectl.h"
#include "tsf.h"

#define    NUM_LANGBAR_ITEM_BUTTON    (2)
#define    NUM_TSF_GETITEMS        (15)
#define    TSF_WAITTIME            (3 * 1000)

static    ITfThreadMgr*        _QueryThreadMgr (void);
static    ITfLangBarItemMgr*    _QueryLangBarItemMgr (void);
static    BOOL            InitOtherLangBarItem (void);

static    HMODULE            shMSCTF                = NULL;
static    TfClientId        g_tfClientID;
static    BOOL            g_fInitTSF            = FALSE;

LONG DllAddRef(void)
{
    return TRUE;
}

//+---------------------------------------------------------------------------
//
//  DllRelease
//
//----------------------------------------------------------------------------

LONG DllRelease(void)
{
    return TRUE;
}


// {830DE831-E04D-40bb-8683-1E179A5F1A4F}
/*
 *    偙偺 class id 偼 skimic.dll 偺棙梡偟偰偄傞傕偺偩偑丄偙傟傪巊偭偰偼偄偗側偄
 *    傛偆偩丅幚嵺偵巊偆 class id 偵偮偄偰偼乧
 *
 */
#if 0
const CLSID    c_clsidSaenaruTextService    = {
    0x830de831, 0xe04d, 0x40bb, { 0x86, 0x83, 0x1e, 0x17, 0x9a, 0x5f, 0x1a, 0x4f }
};
#endif
/*    偙偺 IME 偲偄偆??儞偲摨偠 CLSID 偵愝掕偡傞昁梫偑偁傞傛偆偩丅MS-IME2002 偺
 *    嫇摦傪嶲徠偡傞偵丅
 */
#if 1
const CLSID c_clsidSaenaruTextService    = {
    //0x77B34286, 0xED57, 0x45E2, { 0x97, 0x66, 0xD8, 0xC5, 0xFE, 0x3D, 0xFB, 0x2C }
    0x766a2c15, 0xb226, 0x4fd6, { 0xb5, 0x2a, 0x86, 0x7b, 0x3E, 0xbf, 0x38, 0xd2 }
};
#endif

// {930C0CDC-A91F-4d7c-B23A-67749D4EBFCD}
const GUID c_guidSaenaruProfile = {
    0x930c0cdc, 0xa91f, 0x4d7c, { 0xb2, 0x3a, 0x67, 0x74, 0x9d, 0x4e, 0xbf, 0xcd }
};

// {D97B240A-2C61-4b9b-AECF-D5C3CFDDFCBB}
const GUID c_guidItemButtonCMode = {
    //0xd97b240b, 0x2c61, 0x4b9b, { 0xae, 0xcf, 0xd5, 0xc3, 0xcf, 0xdd, 0xfc, 0xbb }
    0xd97b240a, 0x2c61, 0x4b9b, { 0xae, 0xcf, 0xd5, 0xc3, 0xcf, 0xdd, 0xfc, 0xbb }
};

// {68D148D7-E134-45ef-B596-C5EE7915F819}
const GUID c_guidItemButtonIME    = {
    //0x68d148d8, 0xe134, 0x45ef, { 0xb5, 0x96, 0xc5, 0xee, 0x79, 0x15, 0xf8, 0x19 }
    0x68d148d7, 0xe134, 0x45ef, { 0xb5, 0x96, 0xc5, 0xee, 0x79, 0x15, 0xf8, 0x19 }
};

// {D97B240A-2C61-4b9b-AECF-D5C3CFDDFCBB}
const GUID c_guidItemButtonShape = {
    0xd97b240b, 0x2c61, 0x4b9b, { 0xae, 0xcf, 0xd5, 0xc3, 0xcf, 0xdd, 0xfc, 0xbb }
};

/*    摨偠 button 偵尒偊傞偑丄skimic.dll 偲摨偠傕偺傪巊偆偺偼旔偗側偗傟偽側傜側
 *    偄傛偆偩丅摨偠偵偟偰偄傞偺偩偲偄偆愭擖娤偑幐攕偩偭偨乧丅
 */
#if 0
const GUID    c_guidItemButtonCMode = {
    0x82fd14c8, 0xa99a, 0x4882, { 0xa6, 0xe5, 0x74, 0x93, 0xca, 0x67, 0x86, 0x6a }
};

// {EDA78BBB-65F7-4a1b-9551-309D9FE6200C}
const GUID    c_guidItemButtonIME    = {
    0xeda78bbb, 0x65f7, 0x4a1b, { 0x95, 0x51, 0x30, 0x9d, 0x9f, 0xe6, 0x20, 0x0c }
};
#endif

/*    僉???僪??儞偺 GUID丅嫲傜偔偼偙偺抣偱堦堄偵寛掕偡傞敜丅
 */
#if 1
const GUID c_guidKeyboardItemButton    = {
    0x34745C63, 0xB2F0, 0x4784, { 0x8B, 0x67, 0x5E, 0x12, 0xC8, 0x70, 0x1A, 0x31 }
};
#endif

BOOL PASCAL
InitLanguageBar (void)
{
    register ITfLangBarItemMgr*    pLangBarItemMgr            = NULL;
#if defined (TSF_NEED_MUTEX)
    register HANDLE  hMutex;
    register DWORD   dwValue;
#endif
    register BOOL    fRet = FALSE;
    register HRESULT hr;
    register int     i;
        
    DEBUGPRINTF ((TEXT ("Enter::InitLanguageBar\n")));

    /* Logon 帪偵偼 TSF 偼屇傃弌偝側偄丅*/
#if 0
    if (gfSaenaruSecure) {
        DEBUGPRINTF ((TEXT ("Leave::InitLanguageBar - security\n")));
        return    FALSE;
    }
#endif
#if defined (TSF_NEED_MUTEX)
    hMutex = saenaruCreateMutex (SKKIME_MUTEX_NAME);
    if (!hMutex) 
        return FALSE;

    dwValue = WaitForSingleObject (hMutex, TSF_WAITTIME);
    if (dwValue == WAIT_FAILED || dwValue == WAIT_TIMEOUT) 
        goto Exit_Func_1;
#endif    
    if (g_fInitTSF) {
        fRet = TRUE;
        goto Exit_Func;
    }

    shMSCTF = LoadLibrary (TEXT ("msctf.dll"));
    if (shMSCTF == NULL) {
        DEBUGPRINTF ((TEXT ("Leave::InitLanguageBar - mstcf.dll not found\n")));
        goto Exit_Func;
    }
    fRet = TRUE;
    g_fInitTSF = TRUE;

 Exit_Func:
    DEBUGPRINTFEX (99, (TEXT ("InitLanguageBar () = %d\n"), fRet));
    if (! fRet)
    {
        DEBUGPRINTFEX (99, (TEXT ("InitLanguageBar failed.\n")));
        if (shMSCTF != NULL)
	{
            FreeLibrary (shMSCTF);
            shMSCTF = NULL;
        }
    }
#if defined (TSF_NEED_MUTEX)
    ReleaseMutex (hMutex);
  Exit_Func_1:
    CloseHandle (hMutex);
#endif
    DEBUGPRINTF ((TEXT ("Leave::InitLanguageBar - %d\n"), fRet));
    return fRet;
}

BOOL    PASCAL
IsTSFEnabled (void)
{
    register HMODULE hMSCTF;
    register BOOL fRetval;

    if (g_fInitTSF)
        return (shMSCTF != NULL);

    hMSCTF = LoadLibrary (TEXT ("msctf.dll"));
    if (hMSCTF != NULL) {
        FreeLibrary (hMSCTF);
        fRetval = TRUE;
    } else {
        fRetval = FALSE;
    }
    return fRetval;
}

BOOL    PASCAL
UpdateLanguageBarIfSelected (void)
{
    TCHAR    szFile [32];
    HKL        hKL;

    hKL    = GetKeyboardLayout (0);
    ImmGetIMEFileName (hKL, szFile, sizeof (szFile) / sizeof (TCHAR));
    if (!lstrcmpi (szFile, MyFileName)) 
        return    UpdateLanguageBar ();
    return    FALSE;
}

BOOL    PASCAL
UpdateLanguageBar (void)
{
    register ITfLangBarItemMgr* pLangBarItemMgr = NULL;
    register ITfThreadMgr*      pThreadMgr;
#if defined (TSF_NEED_MUTEX)
    register HANDLE hMutex;
#endif
    register DWORD  dwValue;
    register BOOL   fRetval = FALSE;
    register BOOL   fShowKeyboardIcon, fShowIMEIcon, fShowInputModeIcon, fShowShapeIcon;

#if 0
    if (gfSaenaruSecure)
        return    FALSE;
#endif

#if defined (TSF_NEED_MUTEX)
    hMutex    = saenaruCreateMutex (SKKIME_MUTEX_NAME);
    if (!hMutex) 
        return    FALSE;

    dwValue    = WaitForSingleObject (hMutex, TSF_WAITTIME);
    if (dwValue == WAIT_FAILED || dwValue == WAIT_TIMEOUT) 
        goto    exit_func_1;
#endif
    if (shMSCTF == NULL)
        goto    exit_func;

    DEBUGPRINTFEX (100, (TEXT ("UpdateLanguageBar ()\n")));

    /*    枅夞儗僕僗僩儕傪嶲徠偡傞偺偼惓偟偄偺偩傠偆偐丠 */
    fShowKeyboardIcon = fShowIMEIcon = fShowInputModeIcon = fShowShapeIcon = TRUE;
#if 0
#if !defined (NO_TOUCH_REGISTRY)
    if (GetRegDwordValue (TEXT ("\\CICERO"), TEXT(REGKEY_SHOWKEYBRDICON), &dwValue))
        fShowKeyboardIcon    = (BOOL) dwValue;
    if (GetRegDwordValue (TEXT ("\\CICERO"), TEXT(REGKEY_SHOWIMEICON), &dwValue))
        fShowIMEIcon        = (BOOL) dwValue;
    if (GetRegDwordValue (TEXT ("\\CICERO"), TEXT(REGKEY_SHOWINPUTMODEICON), &dwValue))
        fShowInputModeIcon    = (BOOL) dwValue;
    // XXX
    if (GetRegDwordValue (TEXT ("\\CICERO"), TEXT(REGKEY_SHOWTOGGLEICON), &dwValue))
        fShowInputModeIcon    = (BOOL) dwValue;
#endif
#endif
    pLangBarItemMgr    = _QueryLangBarItemMgr ();
    if (pLangBarItemMgr != NULL) {
        ITfLangBarItem*        pItem;
        ITfLangBarItem*        pNewItem;
        
        if (fShowInputModeIcon) {
            pItem    = NULL;
            if (SUCCEEDED (pLangBarItemMgr->GetItem (c_guidItemButtonCMode, &pItem)) &&
                pItem != NULL) {
                pLangBarItemMgr->RemoveItem (pItem);
                if (fShowInputModeIcon) 
                    pLangBarItemMgr->AddItem (pItem);
                pItem->Release ();
            }
        }
#if 1
        if (fShowShapeIcon) {
            pItem    = NULL;
            if (SUCCEEDED (pLangBarItemMgr->GetItem (c_guidItemButtonShape, &pItem)) &&
                pItem != NULL) {
                pLangBarItemMgr->RemoveItem (pItem);
                if (fShowShapeIcon) 
                    pLangBarItemMgr->AddItem (pItem);

⌨️ 快捷键说明

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