Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
Een IME-bewuste toepassing die het bericht WM_IME_COMPOSITION verwerkt, test de bits in parameter lParam en roept de functie ImmGetCompositionString aan om de aangegeven tekenreeks of gegevens op te halen. In het volgende voorbeeld wordt gecontroleerd op de resultaattekenreeks, voldoende geheugen toegewezen voor de tekenreeks en wordt de resultaattekenreeks opgehaald uit de IME.
HIMC hIMC;
DWORD dwSize;
HGLOBAL hstr;
LPSTR lpstr;
case WM_IME_COMPOSITION:
if (lParam & GCS_RESULTSTR)
{
hIMC = ImmGetContext(hWnd);
if (!hIMC)
MyError(ERROR_NULLCONTEXT);
// Get the size of the result string.
dwSize = ImmGetCompositionString(hIMC, GCS_RESULTSTR, NULL, 0);
// increase buffer size for terminating null character,
// maybe it is in UNICODE
dwSize += sizeof(WCHAR);
hstr = GlobalAlloc(GHND,dwSize);
if (hstr == NULL)
MyError(ERROR_GLOBALALLOC);
lpstr = (LPSTR)GlobalLock(hstr);
if (lpstr == NULL)
MyError(ERROR_GLOBALLOCK);
// Get the result strings that is generated by IME into lpstr.
ImmGetCompositionString(hIMC, GCS_RESULTSTR, lpstr, dwSize);
ImmReleaseContext(hWnd, hIMC);
// add this string into text buffer of application
GlobalUnlock(hstr);
GlobalFree(hstr);
}
Verwante onderwerpen