MyGUI 3.0 支持中文显示及中文输入

□ 更改配置文件MyGUI3.0\Media\MyGUI_Media下

☆ core_font.xml添加

<Resource type="ResourceTrueTypeFont" name="font_Simhei">
        <Property key="Source" value="simhei.ttf"/>
        <Property key="Size" value="19"/>
        <Property key="Resolution" value="50"/>
        <Property key="Antialias" value="false"/>
        <Property key="SpaceWidth" value="4"/>
        <Property key="TabWidth" value="8"/>
        <Property key="CursorWidth" value="2"/>
        <Property key="Distance" value="6"/>
        <Property key="OffsetHeight" value="0"/>
        <Codes>
            <Code range="33 126"/>
            <Code range="19969 40869"/>
            <Code hide="128"/>
            <Code hide="1026 1039"/>
            <Code hide="1104"/>
        </Codes>
    </Resource>

☆ simhei.ttf要从系统目录下的Fonts拷贝到当前目录。

☆ core_settings.xml中将默认字体改成

    <MyGUI type="Font">
        <Property key="Default" value="font_Simhei"/>
    </MyGUI>

☆ mMainWidget->setCaption(L"Console颜色窗口");

□ 支持中文输入

在BaseManger.cpp中

void BaseManager::injectKeyPress(MyGUI::KeyCode _key, MyGUI::Char _text)
{
if (!mGUI)
return;

if(ImmIsIME(GetKeyboardLayout(0)))
{
size_t handle = 0;
mWindow->getCustomAttribute("WINDOW", &handle);
HWND hWnd = (HWND)handle;

HIMC hIMC;
DWORD dwSize;
WCHAR lpWideStr[20];
memset(lpWideStr, 0, 20);
hIMC = ImmGetContext(hWnd);
dwSize = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
dwSize += sizeof(WCHAR);
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpWideStr, dwSize);
for (INT i = 0; i < dwSize ;i++)
{
mGUI->injectKeyPress(_key, lpWideStr[i]);
}
ImmReleaseContext(hWnd, hIMC);
return;
}

...原有代码省略…
}
image

你可能感兴趣的:(GUI)