IMEで入力したカタカナを取得

「あいうえお」と入力して確定すると「アイウエオ」を取得
「三毛猫ホームズ」と入力して確定すると「ミケネコホームズ」

if(pMsg->message == WM_IME_COMPOSITION && (pMsg->lParam & GCS_RESULTREADSTR) != 0){
    HIMC himc = ImmGetContext(m_rich2.m_hWnd);
    CString str1,str2;
		
    //バッファ確保のため入力したバイト数を取得
    int nLen = ImmGetCompositionString(himc, GCS_RESULTREADSTR,NULL, 0);
    //入力文字列取得
    ImmGetCompositionString(himc, GCS_RESULTREADSTR,str1.GetBufferSetLength(nLen),nLen);
    //コンテキスト開放
    ImmReleaseContext(m_rich2.m_hWnd,himc);
    str2.Format("nLen == %d, nstr == %d, str==%s\n",nLen,str1.GetLength(),str1);
    TRACE(str2);
}