Example #1
0
void Mint::EnableIME(bool bEnable)
{
	_ASSERT(GetHWND());
	if ( (bEnable == true) && MEvent::GetIMESupport()) {
		if (m_hImc) {
			ImmAssociateContext(GetHWND(), m_hImc);
			m_hImc = NULL;	// EnableIME(false) ÇÒ¶§ ´Ù½Ã ¼ÂÆõȴÙ
			::SetFocus(GetHWND());
		}
		m_bEnableIME = true;
	} else {
		// HIMC¸¦ m_hImc¿¡ Àӽà º¸°üÇØ µ×´Ù°¡, Enable¶§ º¹±¸ÇÑ´Ù.
		m_hImc = ImmGetContext(GetHWND());
		if (m_hImc) {
			ImmAssociateContext(GetHWND(), NULL);
			ImmReleaseContext(GetHWND(), m_hImc);
			::SetFocus(GetHWND());
		}
		//ImmDisableIME(0);
		m_bEnableIME = false;
	}

	// CompositionÁßÀÎ ¹®ÀÚ¿­ Á¦°Å
	HIMC hImc = ImmGetContext(GetInstance()->GetHWND());
	if(hImc!=NULL){
		ImmNotifyIME(hImc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
		ImmReleaseContext(GetInstance()->GetHWND(), hImc);
	}
}
Example #2
0
static LONG WINAPI handle(HWND win, UINT msg, WPARAM w, LPARAM l) {
        LONG r;
        switch (msg) {
#define HANDLE(x) case WM_##x: cvReport("han " #x); r = HANDLE_WM_##x(win, w, l, on##x); break
                HANDLE(TIMER);
                HANDLE(PAINT);
                HANDLE(MOUSEMOVE);
                HANDLE(SIZE);
                HANDLE(KEYDOWN);
                HANDLE(SYSKEYDOWN);
                HANDLE(SYSKEYUP);
                HANDLE(CHAR);
                HANDLE(KEYUP);
                HANDLE(LBUTTONDOWN);
                HANDLE(RBUTTONDOWN);
                HANDLE(MBUTTONDOWN);
                HANDLE(LBUTTONUP);
                HANDLE(RBUTTONUP);
                HANDLE(MBUTTONUP);
                HANDLE(MOUSEWHEEL);
                HANDLE(DESTROY);
                HANDLE(CLOSE);
#undef HANDLE
        case WM_IME_STARTCOMPOSITION: {
                HIMC imc = ImmGetContext(win);
                COMPOSITIONFORM cf;
                cf.dwStyle = CFS_POINT;
                cf.ptCurrentPos.x = cvMouseX();
                cf.ptCurrentPos.y = cvMouseY();
                ImmSetCompositionWindow(imc, &cf);
                ImmReleaseContext(win, imc);
                r = 1;
        }
        break;
        case WM_IME_COMPOSITION: {
                if(l & GCS_RESULTSTR){
                        unsigned short str[4096];
                        unsigned len, i; 
                        HIMC imc = ImmGetContext(win);
                        HDC dc = GetDC(win);
                        len = ImmGetCompositionString(imc, GCS_RESULTSTR, str, sizeof(str));
                        len >>= 1;
                        for (i = 0; i < len; i++)
                                wgot(win, CVE_UNICODE, str[i], 0); 
                        ImmReleaseContext(win, imc);
                        chk(ReleaseDC(win, dc));
                }
                r = 0;
        }
        break;
        default: r = 0;
        }
Example #3
0
File: imm32.c Project: krofna/wine
static void test_ImmGetContext(void)
{
    HIMC himc;
    DWORD err;

    SetLastError(0xdeadbeef);
    himc = ImmGetContext((HWND)0xffffffff);
    err = GetLastError();
    ok(himc == NULL, "ImmGetContext succeeded\n");
    ok(err == ERROR_INVALID_WINDOW_HANDLE, "got %u\n", err);

    himc = ImmGetContext(hwnd);
    ok(himc != NULL, "ImmGetContext failed\n");
    ok(ImmReleaseContext(hwnd, himc), "ImmReleaseContext failed\n");
}
Example #4
0
File: imm32.c Project: krofna/wine
static void test_ImmMessages(void)
{
    CANDIDATEFORM cf;
    imm_msgs *msg;
    HWND defwnd;
    HIMC imc;
    UINT idx = 0;

    HWND hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "Wine imm32.dll test",
                          WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
                          240, 120, NULL, NULL, GetModuleHandle(0), NULL);

    ShowWindow(hwnd, SW_SHOWNORMAL);
    defwnd = ImmGetDefaultIMEWnd(hwnd);
    imc = ImmGetContext(hwnd);

    ImmSetOpenStatus(imc, TRUE);
    msg_spy_flush_msgs();
    SendMessage(defwnd, WM_IME_CONTROL, IMC_GETCANDIDATEPOS, (LPARAM)&cf );
    do
    {
        msg = msg_spy_find_next_msg(WM_IME_CONTROL,&idx);
        if (msg) ok(!msg->post, "Message should not be posted\n");
    } while (msg);
    msg_spy_flush_msgs();
    ImmSetOpenStatus(imc, FALSE);
    ImmReleaseContext(hwnd, imc);
    DestroyWindow(hwnd);
}
Example #5
0
File: imm32.c Project: krofna/wine
static void test_ImmSetCompositionString(void)
{
    HIMC imc;
    BOOL ret;

    SetLastError(0xdeadbeef);
    imc = ImmGetContext(hwnd);
    ok(imc != 0, "ImmGetContext() failed. Last error: %u\n", GetLastError());
    if (!imc)
        return;

    ret = ImmSetCompositionStringW(imc, SCS_SETSTR, NULL, 0, NULL, 0);
    ok(broken(!ret) ||
       ret, /* Vista+ */
       "ImmSetCompositionStringW() failed.\n");

    ret = ImmSetCompositionStringW(imc, SCS_SETSTR | SCS_CHANGEATTR,
        NULL, 0, NULL, 0);
    ok(!ret, "ImmSetCompositionStringW() succeeded.\n");

    ret = ImmSetCompositionStringW(imc, SCS_SETSTR | SCS_CHANGECLAUSE,
        NULL, 0, NULL, 0);
    ok(!ret, "ImmSetCompositionStringW() succeeded.\n");

    ret = ImmSetCompositionStringW(imc, SCS_CHANGEATTR | SCS_CHANGECLAUSE,
        NULL, 0, NULL, 0);
    ok(!ret, "ImmSetCompositionStringW() succeeded.\n");

    ret = ImmSetCompositionStringW(imc, SCS_SETSTR | SCS_CHANGEATTR | SCS_CHANGECLAUSE,
        NULL, 0, NULL, 0);
    ok(!ret, "ImmSetCompositionStringW() succeeded.\n");

    ImmReleaseContext(hwnd, imc);
}
Example #6
0
File: ime.c Project: emonkak/cereja
static int
ui_ime_get_state(lua_State* L)
{
HWND hwnd;
	HIMC himc;
	DWORD conversion;
	DWORD sentence;

	hwnd = GetForegroundWindow();
	himc = ImmGetContext(hwnd);
	ImmGetConversionStatus(himc, &conversion, &sentence);
	Crj_BuildValues(L, "{Qll}",
					ImmGetOpenStatus(himc),
					conversion,
					sentence);

	char text[256];
	sprintf(text, "[%p] [%d] [%lx] [%lx]",
			(void*)hwnd,
			ImmGetOpenStatus(himc),
			conversion,
			sentence
			);
	MessageBox(NULL, text, "cereja", MB_OK);

	ImmReleaseContext(hwnd, himc);

	return 1;
}
Example #7
0
void imedel(){
	//imeをオフ
	HIMC hImc;
	hImc = ImmGetContext( hWnd );
	ImmSetOpenStatus(hImc, false);
	ImmReleaseContext(hWnd, hImc);
}
Example #8
0
	LRESULT CDuiWkeWebkit::OnImeStartComposition( UINT uMsg, WPARAM wParam,LPARAM lParam )
	{
		wkeRect caret = m_pWebView->getCaret();

		CRect rcClient;
		GetClient(&rcClient);

		CANDIDATEFORM form;
		form.dwIndex = 0;
		form.dwStyle = CFS_EXCLUDE;
		form.ptCurrentPos.x = caret.x + rcClient.left;
		form.ptCurrentPos.y = caret.y + caret.h + rcClient.top;
		form.rcArea.top = caret.y + rcClient.top;
		form.rcArea.bottom = caret.y + caret.h + rcClient.top;
		form.rcArea.left = caret.x + rcClient.left;
		form.rcArea.right = caret.x + caret.w + rcClient.left;
		COMPOSITIONFORM compForm;
		compForm.ptCurrentPos=form.ptCurrentPos;
		compForm.rcArea=form.rcArea;
		compForm.dwStyle=CFS_POINT;

		HWND hWnd=GetContainer()->GetHostHwnd();
		HIMC hIMC = ImmGetContext(hWnd);
		ImmSetCandidateWindow(hIMC, &form);
		ImmSetCompositionWindow(hIMC,&compForm);
		ImmReleaseContext(hWnd, hIMC);
		return 0;
	}
Example #9
0
// &SetImeString
static void funcSetImeString(HWND i_hwnd, int i_size)
{
    _TCHAR *buf = new _TCHAR(i_size);
    DWORD len = 0;
    _TCHAR ImeDesc[GANA_MAX_ATOM_LENGTH];
    UINT ImeDescLen;
    DWORD error;
    DWORD denom = 1;
    HANDLE hPipe
        = CreateFile(addSessionId(HOOK_PIPE_NAME).c_str(), GENERIC_READ,
                     FILE_SHARE_READ, (SECURITY_ATTRIBUTES *)NULL,
                     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
    error = ReadFile(hPipe, buf, i_size, &len, NULL);
    CloseHandle(hPipe);

    ImeDescLen = ImmGetDescription(GetKeyboardLayout(0),
                                   ImeDesc, sizeof(ImeDesc));
    if (_tcsncmp(ImeDesc, _T("SKKIME"), ImeDescLen) > 0)
        denom = sizeof(_TCHAR);

    HIMC hIMC = ImmGetContext(i_hwnd);
    if (hIMC == INVALID_HANDLE_VALUE)
        return;

    int status = ImmGetOpenStatus(hIMC);
    ImmSetCompositionString(hIMC, SCS_SETSTR, buf, len / denom, NULL, 0);
    delete buf;
    ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
    if (!status)
        ImmSetOpenStatus(hIMC, status);
    ImmReleaseContext(i_hwnd, hIMC);
}
Example #10
0
LRESULT CWkeWebkitWnd::OnImeStartComposition(UINT uMsg, WPARAM wParam,LPARAM lParam, BOOL& bHandled)
{
	wkeRect caret = m_pWebView->getCaret();

	RECT rcClient;
	GetClientRect(m_hWnd, &rcClient);

	CANDIDATEFORM form;
	form.dwIndex = 0;
	form.dwStyle = CFS_EXCLUDE;
	form.ptCurrentPos.x = caret.x + rcClient.left;
	form.ptCurrentPos.y = caret.y + caret.h + rcClient.top;
	form.rcArea.top = caret.y + rcClient.top;
	form.rcArea.bottom = caret.y + caret.h + rcClient.top;
	form.rcArea.left = caret.x + rcClient.left;
	form.rcArea.right = caret.x + caret.w + rcClient.left;
	COMPOSITIONFORM compForm;
	compForm.ptCurrentPos=form.ptCurrentPos;
	compForm.rcArea=form.rcArea;
	compForm.dwStyle=CFS_POINT;

	HWND hWnd=m_pOwner->GetManager()->GetPaintWindow();
	HIMC hIMC = ImmGetContext(hWnd);
	ImmSetCandidateWindow(hIMC, &form);
	ImmSetCompositionWindow(hIMC,&compForm);
	ImmReleaseContext(hWnd, hIMC);

	//bHandled = TRUE;
	return 0;
}
Example #11
0
DWORD
GetNLSMode(
    HWND hWnd,
    HANDLE hConsole
    )
{
    PCONSOLE_TABLE ConTbl;
    HIMC hIMC;

    ConTbl = SearchConsole(hConsole);
    if (ConTbl == NULL) {
        DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
        return 0;
    }

    hIMC = ImmGetContext( hWnd ) ;
    if ( hIMC == (HIMC)NULL )
        return IME_CMODE_DISABLE;

    ImmGetConversionStatus(hIMC,
                           &ConTbl->dwConversion,
                           &ConTbl->dwSentence);
    ConTbl->fOpen = GetOpenStatusByCodepage( hIMC, ConTbl ) ;

    ImmReleaseContext( hWnd, hIMC );


    return ((ConTbl->fOpen ? IME_CMODE_OPEN : 0) + ConTbl->dwConversion);
}
Example #12
0
/** Set the position of the candidate window. */
static void SetCandidatePos(HWND hwnd)
{
	HIMC hIMC = ImmGetContext(hwnd);
	if (hIMC != NULL) {
		CANDIDATEFORM cf;
		cf.dwIndex = 0;
		cf.dwStyle = CFS_EXCLUDE;

		if (EditBoxInGlobalFocus()) {
			Point pt = _focused_window->GetCaretPosition();
			cf.ptCurrentPos.x = _focused_window->left + pt.x;
			cf.ptCurrentPos.y = _focused_window->top  + pt.y;
			if (_focused_window->window_class == WC_CONSOLE) {
				cf.rcArea.left   = _focused_window->left;
				cf.rcArea.top    = _focused_window->top;
				cf.rcArea.right  = _focused_window->left + _focused_window->width;
				cf.rcArea.bottom = _focused_window->top  + _focused_window->height;
			} else {
				cf.rcArea.left   = _focused_window->left + _focused_window->nested_focus->pos_x;
				cf.rcArea.top    = _focused_window->top  + _focused_window->nested_focus->pos_y;
				cf.rcArea.right  = cf.rcArea.left + _focused_window->nested_focus->current_x;
				cf.rcArea.bottom = cf.rcArea.top  + _focused_window->nested_focus->current_y;
			}
		} else {
			cf.ptCurrentPos.x = 0;
			cf.ptCurrentPos.y = 0;
			SetRectEmpty(&cf.rcArea);
		}
		ImmSetCandidateWindow(hIMC, &cf);
	}
	ImmReleaseContext(hwnd, hIMC);
}
BOOL CreateTBar(HWND hWnd)
{
    HIMC hIMC = NULL;
    BOOL fOpen;

    hWndToolBar = CreateToolbarEx(hWnd,
                                  WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS,
                                  TOOLBAR_ID,
                                  NUMIMAGES,
                                  hInst,
                                  IDB_BMP,
                                  tbButton,
                                  sizeof(tbButton)/sizeof(TBBUTTON),
                                  BUTTONWIDTH,
                                  BUTTONHEIGHT,
                                  IMAGEWIDTH,
                                  IMAGEHEIGHT,
                                  sizeof(TBBUTTON));

    UpdateShowCandButton();

    hIMC = ImmGetContext(hWndCompStr);
    fOpen = ImmGetOpenStatus(hIMC);
    UpdateShowOpenStatusButton(fOpen);
    ImmReleaseContext(hWndCompStr,hIMC);

    return (hWndToolBar != 0);
}
Example #14
0
HIMC pymImmGetContext(HWND hWnd) {
	PyMFC_PROLOGUE(pymFormatMessage);
	{
		PyMFCLeavePython lp;
		return ImmGetContext(hWnd);
	}
	PyMFC_EPILOGUE(0);
}
Example #15
0
void JIme::ResetComposition()
{
	HWND hWnd = JMain::GetInstance().GetJWindow().GetWindowHandle();
	HIMC hImc = ImmGetContext(hWnd);
	ImmSetCompositionString(hImc, SCS_SETSTR, NULL, 0, NULL, 0);
	ImmReleaseContext(hWnd, hImc);
	ZeroMemory(&ime_comp_char, 3*sizeof(TCHAR));
}
Example #16
0
/** Handle WM_IME_COMPOSITION messages. */
static LRESULT HandleIMEComposition(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
	HIMC hIMC = ImmGetContext(hwnd);

	if (hIMC != NULL) {
		if (lParam & GCS_RESULTSTR) {
			/* Read result string from the IME. */
			LONG len = ImmGetCompositionString(hIMC, GCS_RESULTSTR, NULL, 0); // Length is always in bytes, even in UNICODE build.
			TCHAR *str = (TCHAR *)_alloca(len + sizeof(TCHAR));
			len = ImmGetCompositionString(hIMC, GCS_RESULTSTR, str, len);
			str[len / sizeof(TCHAR)] = '\0';

			/* Transmit text to windowing system. */
			if (len > 0) {
				HandleTextInput(NULL, true); // Clear marked string.
				HandleTextInput(FS2OTTD(str));
			}
			SetCompositionPos(hwnd);

			/* Don't pass the result string on to the default window proc. */
			lParam &= ~(GCS_RESULTSTR | GCS_RESULTCLAUSE | GCS_RESULTREADCLAUSE | GCS_RESULTREADSTR);
		}

		if ((lParam & GCS_COMPSTR) && DrawIMECompositionString()) {
			/* Read composition string from the IME. */
			LONG len = ImmGetCompositionString(hIMC, GCS_COMPSTR, NULL, 0); // Length is always in bytes, even in UNICODE build.
			TCHAR *str = (TCHAR *)_alloca(len + sizeof(TCHAR));
			len = ImmGetCompositionString(hIMC, GCS_COMPSTR, str, len);
			str[len / sizeof(TCHAR)] = '\0';

			if (len > 0) {
				static char utf8_buf[1024];
				convert_from_fs(str, utf8_buf, lengthof(utf8_buf));

				/* Convert caret position from bytes in the input string to a position in the UTF-8 encoded string. */
				LONG caret_bytes = ImmGetCompositionString(hIMC, GCS_CURSORPOS, NULL, 0);
				const char *caret = utf8_buf;
				for (const TCHAR *c = str; *c != '\0' && *caret != '\0' && caret_bytes > 0; c++, caret_bytes--) {
					/* Skip DBCS lead bytes or leading surrogates. */
#ifdef UNICODE
					if (Utf16IsLeadSurrogate(*c)) {
#else
					if (IsDBCSLeadByte(*c)) {
#endif
						c++;
						caret_bytes--;
					}
					Utf8Consume(&caret);
				}

				HandleTextInput(utf8_buf, true, caret);
			} else {
				HandleTextInput(NULL, true);
			}

			lParam &= ~(GCS_COMPSTR | GCS_COMPATTR | GCS_COMPCLAUSE | GCS_CURSORPOS | GCS_DELTASTART);
		}
	}
void CTextInputCtrl::SetCompositionFont()
{
    HIMC himc = ImmGetContext(_hwnd);
    if (himc)
    {
        ImmSetCompositionFont(himc, &_lfCurrentFont);
    }
    ImmReleaseContext(_hwnd, himc);
}
Example #18
0
File: ime.c Project: AmesianX/wine
void IME_UpdateAssociation(HWND focus)
{
    ImmGetContext(focus);

    if (!focus || !hSelectedFrom)
        return;

    ImmAssociateContext(focus,RealIMC(FROM_X11));
}
Example #19
0
//--------------------------------------------------------------------------
void VeWindows::_DisableIME(Window* pkWindow)
{
	WindowData* pkData = (WindowData*)(VeRefObject*)pkWindow->m_spDriverData;
	if(!pkData->m_hImc)
	{
		pkData->m_hImc = ImmGetContext(pkData->m_hWnd);
		ImmAssociateContext(pkData->m_hWnd, NULL);
	}
}
Example #20
0
WCHAR* IME_getCompositionString() {
	HWND hwnd = GetFocus();
	if (!hwnd)  return NULL;
	HIMC imc = ImmGetContext(hwnd);
	if (!imc)  return NULL;
	WCHAR* comp_str = getCompositionString(imc, GCS_COMPSTR);
	ImmReleaseContext(hwnd, imc);
	return comp_str;
}
Example #21
0
// Called by CUIDialogResMgr::OnCreateDevice.  This gives the class a
// chance to initialize its default input context associated with the app window.
HRESULT CIME::StaticOnCreateDevice()
{
	// Save the default input context
	s_hImcDef = ImmGetContext(UIGetHWND());
	//s_hImcDef = _ImmGetContext(UIGetHWND());
	_ImmReleaseContext(UIGetHWND(), s_hImcDef);

	return S_OK;
}
Example #22
0
void JIme::SetImeMode(const DWORD mode)
{
	HWND hWnd = JMain::GetInstance().GetJWindow().GetWindowHandle();
	HIMC hImc = ImmGetContext(hWnd);
	DWORD dwConv, dwSent;
	ImmGetConversionStatus(hImc, &dwConv, &dwSent);
	ImmSetConversionStatus(hImc, mode, dwSent);
	ImmReleaseContext(hWnd, hImc);
}
void CTextEditor::FlushCompositionString()
{
    // We flush the composition string at selection change.
    HIMC himc = ImmGetContext(_hwnd);
    if (himc)
    {
        ImmNotifyIME(himc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
        ImmReleaseContext(_hwnd, himc);
    }
}
Example #24
0
// Notify OS Input Method Editor of text input position (e.g. when using Japanese/Chinese inputs, otherwise this isn't needed)
static void ImImpl_ImeSetInputScreenPosFn( int x, int y ) {
	HWND hwnd = glfwGetWin32Window( g_Window );
	if ( HIMC himc = ImmGetContext( hwnd ) ) {
		COMPOSITIONFORM cf;
		cf.ptCurrentPos.x = x;
		cf.ptCurrentPos.y = y;
		cf.dwStyle = CFS_FORCE_POSITION;
		ImmSetCompositionWindow( himc, &cf );
	}
}
Example #25
0
// Cancel current IME composition.
static inline void imeNotifyCancelComposition(HWND hwnd)
{
    if (!hwnd) {
        qWarning() << __FUNCTION__ << "called with" << hwnd;
        return;
    }
    const HIMC himc = ImmGetContext(hwnd);
    ImmNotifyIME(himc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
    ImmReleaseContext(hwnd, himc);
}
Example #26
0
CIme::CIme( HWND hWnd )
: m_hWnd( hWnd )
, m_uCharBuf(0)
, m_bEnableIme(true)
, m_hCurKL( NULL )
, m_hImc( NULL )
{
	m_hCurKL	= GetKeyboardLayout( 0 );
	m_hImc		= ImmGetContext( m_hWnd );
	//SetImeIcon();
}
bool QWindowsInputContext::composition(HWND hwnd, LPARAM lParamIn)
{
    QObject *fo = qApp->focusObject();
    const int lParam = int(lParamIn);
    if (QWindowsContext::verboseInputMethods)
        qDebug() << '>' << __FUNCTION__ << fo << debugComposition(lParam)
                 << " composing=" << m_compositionContext.isComposing;
    if (!fo || m_compositionContext.hwnd != hwnd || !lParam)
        return false;
    const HIMC himc = ImmGetContext(m_compositionContext.hwnd);
    if (!himc)
        return false;

    QScopedPointer<QInputMethodEvent> event;
    if (lParam & (GCS_COMPSTR | GCS_COMPATTR | GCS_CURSORPOS)) {
        if (!m_compositionContext.isComposing)
            startContextComposition();
        // Some intermediate composition result. Parametrize event with
        // attribute sequence specifying the formatting of the converted part.
        int selStart, selLength;
        m_compositionContext.composition = getCompositionString(himc, GCS_COMPSTR);
        m_compositionContext.position = ImmGetCompositionString(himc, GCS_CURSORPOS, 0, 0);
        getCompositionStringConvertedRange(himc, &selStart, &selLength);
        if ((lParam & CS_INSERTCHAR) && (lParam & CS_NOMOVECARET)) {
            // make Korean work correctly. Hope this is correct for all IMEs
            selStart = 0;
            selLength = m_compositionContext.composition.size();
        }
        if (!selLength)
            selStart = 0;

        event.reset(new QInputMethodEvent(m_compositionContext.composition,
                                          intermediateMarkup(m_compositionContext.position,
                                                  m_compositionContext.composition.size(),
                                                  selStart, selLength)));
    }
    if (event.isNull())
        event.reset(new QInputMethodEvent);

    if (lParam & GCS_RESULTSTR) {
        // A fixed result, return the converted string
        event->setCommitString(getCompositionString(himc, GCS_RESULTSTR));
        endContextComposition();
    }
    const bool result = QCoreApplication::sendEvent(fo, event.data());
    if (QWindowsContext::verboseInputMethods)
        qDebug() << '<' << __FUNCTION__ << "sending markup="
                 << event->attributes().size()
                 << " commit=" << event->commitString()
                 << " to " << fo << " returns " << result;
    update(Qt::ImQueryAll);
    ImmReleaseContext(m_compositionContext.hwnd, himc);
    return result;
}
Example #28
0
BOOL
ImeUISetConversionMode(
    HWND hwnd
    )
{
    PCONSOLE_TABLE ConTbl;
    HIMC        hIMC;                   // Input context handle.
    LPCONIME_UIMODEINFO lpModeInfo ;
    COPYDATASTRUCT CopyData ;
    DWORD OldConversion ;


    DBGPRINT(("CONIME: Get IMN_SETCONVERSIONMODE Message\n"));

    ConTbl = SearchConsole(LastConsole);
    if (ConTbl == NULL) {
        DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
        return FALSE;
    }

    hIMC = ImmGetContext( hwnd ) ;
    if ( hIMC == 0 )
        return FALSE;

    lpModeInfo = (LPCONIME_UIMODEINFO)LocalAlloc(LPTR, sizeof(CONIME_UIMODEINFO) ) ;
    if ( lpModeInfo == NULL) {
        ImmReleaseContext( hwnd, hIMC );
        return FALSE;
    }

    OldConversion = ConTbl->dwConversion ;

    ImmGetConversionStatus(hIMC,
                           (LPDWORD)&ConTbl->dwConversion,
                           (LPDWORD)&ConTbl->dwSentence) ;

    CopyData.dwData = CI_CONIMEMODEINFO ;
    CopyData.cbData = sizeof(CONIME_UIMODEINFO) ;
    CopyData.lpData = lpModeInfo ;
    if (ImeUIMakeInfoString(ConTbl,
                            lpModeInfo))
    {
        ConsoleImeSendMessage( ConTbl->hWndCon,
                               (WPARAM)hwnd,
                               (LPARAM)&CopyData
                             ) ;
    }

    LocalFree( lpModeInfo );
    ImmReleaseContext( hwnd, hIMC );
    return TRUE ;

}
Example #29
-1
//***********************************************************************
//
// void GetResultStr()
//
// This handles WM_IME_COMPOSITION with GCS_RESULTSTR flag on.
//
//***********************************************************************
void GetResultStr( 
    HWND hwnd )
{
    LONG        bufLen;                 // Storage for length of result str.
    LPSTR       lpResultStr;            // Pointer to result string.
    HIMC        hIMC;                   // Input context handle.
    HLOCAL      hMem;                   // Memory handle.

    //
    // If fail to get input context handle then do nothing.
    //

    if ( !( hIMC = ImmGetContext( hwnd ) ) )
        return;

    //
    // Determines how much memory space to store the result string.
    // Applications should call ImmGetCompositionString with
    // GCS_RESULTSTR flag on, buffer length zero, to get the bullfer
    // length.
    //

    if ( ( bufLen = ImmGetCompositionString( hIMC, GCS_RESULTSTR,
                                  (void *)NULL, (DWORD) 0 ) ) <= 0 )
        goto exit2;

    //
    // Allocates memory with bufLen+1 bytes to store the result
    // string. Here we allocale on more byte to put null character.
    //

    if ( !( hMem = LocalAlloc( LPTR, (int)bufLen + 1 ) ) )
        goto exit2;

    if ( !( lpResultStr = (LPSTR) LocalLock( hMem ) ) )
        goto exit1;

    //
    // Reads in the result string.
    //

    ImmGetCompositionString( hIMC, GCS_RESULTSTR, lpResultStr, bufLen );

    //
    // Displays the result string.
    //

    DisplayResultString( hwnd, lpResultStr );

    LocalUnlock( hMem );

exit1:
    
    LocalFree( hMem );

exit2:

    ImmReleaseContext( hwnd, hIMC );

}
Example #30
-1
bool CIme::OnWM_IME_COMPOSITION( HWND hWnd, LPARAM lParam ){//输入改变
	HIMC hIMC;
	DWORD dwSize;
	hIMC = ImmGetContext( hWnd );
	if( lParam & GCS_COMPSTR ){
		dwSize = ImmGetCompositionString( hIMC, GCS_COMPSTR, (void*)m_szCompStr, sizeof( m_szCompStr ));
		m_szCompStr[ dwSize ] = 0;
	}//取得szCompStr
	if( lParam & GCS_COMPREADSTR ){
		dwSize = ImmGetCompositionString( hIMC, GCS_COMPREADSTR, (void*)m_szCompReadStr, sizeof( m_szCompReadStr ));
		m_szCompReadStr[ dwSize ] = 0;
	}//取得szCompReadStr
	if( lParam & GCS_CURSORPOS ){
		m_nImeCursor = 0xffff & ImmGetCompositionString( hIMC, GCS_CURSORPOS, NULL, 0 );
	}//?〉?.nImeCursor
	if( lParam & GCS_RESULTSTR ){
		unsigned char str[ MAX_PATH ];
		dwSize = ImmGetCompositionString( hIMC, GCS_RESULTSTR, (void*)str, sizeof( str ));//取得汉字输入串
		str[ dwSize ] = 0;
		unsigned char *p = str;
		while( *p )PostMessage( hWnd, WM_CHAR, (WPARAM)(*p++), 1 );//转成WM_CHAR消息
	}
	ImmReleaseContext( hWnd, hIMC );
	return true;//总是返回true,防止ime窗口打开
}