How to Use an Input Context

The following example shows how to use an input context:

LPINPUTCONTEXT lpIMC;
LPCOMOSITIONSTRING lpCompStr;
HIMCC hMyCompStr;
 
if (hIMC) { // It is not NULL context.
    lpIMC = ImmLockIMC(hIMC);
 
    if (!lpIMC) {
        MyError( "Can not lock hIMC");
        return FALSE;
    }
 
    // Use lpIMC->hCompStr.
    lpCompStr = (LPCOMPOSITIONSTRING) ImmLockIMCC(lpIMC->hCompStr);
 
    // Access lpCompStr.
    ImmUnlockIMCC(lpIMC->hCompStr);
 
    // ReSize lpIMC->hCompStr.
    if (!(hMyCompStr = ImmReSizeIMCC(lpIMC->hCompStr,dwNewSize)) {
        MyError("Can not resize hCompStr");
        ImmUnlockIMC(hIMC);
        return FALSE;
    }
    lpIMC->hCompStr = hMyCompStr;
    ImmUnlockIMC(hIMC);
}