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); }
static HRESULT WINAPI ActiveIMMApp_SetCompositionStringW(IActiveIMMApp* This, HIMC hIMC, DWORD dwIndex, LPVOID pComp, DWORD dwCompLen, LPVOID pRead, DWORD dwReadLen) { BOOL rc; rc = ImmSetCompositionStringW(hIMC,dwIndex,pComp,dwCompLen,pRead,dwReadLen); if (rc) return S_OK; else return E_FAIL; }
static void test_ImmGetCompositionString(void) { HIMC imc; static const WCHAR string[] = {'w','i','n','e',0x65e5,0x672c,0x8a9e}; char cstring[20]; WCHAR wstring[20]; DWORD len; DWORD alen,wlen; imc = ImmGetContext(hwnd); ImmSetCompositionStringW(imc, SCS_SETSTR, string, sizeof(string), NULL,0); alen = ImmGetCompositionStringA(imc, GCS_COMPSTR, cstring, 20); wlen = ImmGetCompositionStringW(imc, GCS_COMPSTR, wstring, 20); /* windows machines without any IME installed just return 0 above */ if( alen && wlen) { len = ImmGetCompositionStringW(imc, GCS_COMPATTR, NULL, 0); ok(len*sizeof(WCHAR)==wlen,"GCS_COMPATTR(W) not returning correct count\n"); len = ImmGetCompositionStringA(imc, GCS_COMPATTR, NULL, 0); ok(len==alen,"GCS_COMPATTR(A) not returning correct count\n"); } ImmReleaseContext(hwnd, imc); }
LRESULT HandleChangeAttr(HWND hWnd, BOOL fNext) { BYTE bAttr[512]; BYTE bAttrRead[512]; UINT i,j; UINT uClause; UINT uMaxClause; UINT uCnt; UINT uCntRead; BYTE bAt; BOOL fAttrOK = FALSE; BOOL fAttrReadOK = FALSE; HIMC hIMC = NULL; BOOL bRet = FALSE; uMaxClause = (dwCompClsLen / sizeof(DWORD)) - 1; uClause = GetTargetClause(); if (uClause == (DWORD)-1L) { return 0L; } if (fNext) { if (uClause + 1 <= uMaxClause) { uClause++; } else { return 0L; } } else { if (uClause > 0) { uClause--; } else { return 0L; } } uCnt = 0; if (uClause < uMaxClause) { for (i=0; i < uMaxClause; i++) { if (i == uClause) { switch (bCompAttr[dwCompCls[i]]) { case ATTR_INPUT: bAt = ATTR_TARGET_NOTCONVERTED; break; break; case ATTR_CONVERTED: bAt = ATTR_TARGET_CONVERTED; break; default: bAt = bCompAttr[dwCompCls[i]]; break; } } else { switch (bCompAttr[dwCompCls[i]]) { case ATTR_TARGET_CONVERTED: bAt = ATTR_CONVERTED; break; break; case ATTR_TARGET_NOTCONVERTED: bAt = ATTR_INPUT; break; default: bAt = bCompAttr[dwCompCls[i]]; break; } } for (j = 0; j < (dwCompCls[i+1] - dwCompCls[i]); j++) { bAttr[uCnt++] = bAt; } } fAttrOK = TRUE; } uCntRead = 0; if (uClause < uMaxClause) { for (i=0; i < uMaxClause; i++) { if (i == uClause) { switch (bCompReadAttr[dwCompReadCls[i]]) { case ATTR_INPUT: bAt = ATTR_TARGET_NOTCONVERTED; break; break; case ATTR_CONVERTED: bAt = ATTR_TARGET_CONVERTED; break; default: bAt = bCompReadAttr[dwCompReadCls[i]]; break; } } else { switch (bCompReadAttr[dwCompReadCls[i]]) { case ATTR_TARGET_CONVERTED: bAt = ATTR_CONVERTED; break; break; case ATTR_TARGET_NOTCONVERTED: bAt = ATTR_INPUT; break; default: bAt = bCompReadAttr[dwCompReadCls[i]]; break; } } for (j = 0; j < (dwCompReadCls[i+1] - dwCompReadCls[i]); j++) { bAttrRead[uCntRead++] = bAt; } } fAttrReadOK = TRUE; } if (fAttrReadOK && fAttrOK) { hIMC = ImmGetContext(hWndCompStr); #ifdef USEWAPI bRet = ImmSetCompositionStringW(hIMC,SCS_CHANGEATTR,bAttr,uCnt, bAttrRead,uCntRead); #else bRet = ImmSetCompositionString(hIMC,SCS_CHANGEATTR,bAttr,uCnt, bAttrRead,uCntRead); #endif // bRet = ImmSetCompositionString(hIMC,SCS_CHANGEATTR,NULL,0, // bAttrRead,uCntRead); // bRet = ImmSetCompositionString(hIMC,SCS_CHANGEATTR,bAttr,uCnt, // NULL,0); ImmReleaseContext(hWndCompStr,hIMC); } else { #ifdef DEBUG OutputDebugString("Can not call ImmSetCompositionString\r\n"); bRet = TRUE; #endif } #ifdef DEBUG if (!bRet) { OutputDebugString("ImmSetCompositionString return FALSE\r\n"); } #endif return 1; }