Programming/C#

[삽질] 클라이언트(C++)/툴(C#) 링크 시 IME 문제

blueasa 2010. 9. 9. 17:22

C# - C++/CLI - C++ 연결 후,
IME 때문에 일주일여간 삽질한 걸 잊지 않기 위해 Log 남김.(혼잣말)

1) C# 툴에 C++ 클라이언트를 렌더링하게 클라이언트를 수정(exe를 Lib로 만들어버림)
2) 뜨긴 떴는데..한글이 안먹힘..
3) 디버깅 해보니 한글 변환 메시지가 안들어옴
   (WM_IME_NOTIFY는 들어오는데, IMN_SETCONVERSIONMODE 메시지가 안들어옴)
4) 좀 더 확인해보니 툴의 핸들로 IMC를 Get 하려고 했지만 NULL값이 돌아옴..-_-
5) 클라만 따로 돌리면 IMC 획득 잘하고 , 한/영 변환 잘됨.
6) 일주일여간의 온갖 경우의 수를 생각하며, 인터넷 뒤지며(IME 관련 자료 찾기힘듬..) 삽질..
7) 결국, 마지막으로 한 짓은..
    C#의 IME를 죽이고, IME를 직접 생성해서 사용했음. -_-;
    이것도 임시방편 같기도 하고..맞는건지..
    우선 되니깐..진행..


[사용한 IME 관련 API 함수]
        [DllImport("imm32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr ImmGetContext(IntPtr hWnd);

        [DllImport("imm32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr ImmReleaseContext(IntPtr hWnd, IntPtr hImc);

        [DllImport("imm32.dll", CharSet = CharSet.Auto)]
        public static extern bool ImmGetConversionStatus(IntPtr hImc, out int fdwConversion, out int fdwSentence);

        [DllImport("imm32.dll")]
        public static extern bool ImmSetConversionStatus(IntPtr hIMC, int fdwConversion, int fdwSentence);

[아래는 IME 생성관련 API 함수]
        [DllImport("imm32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr ImmCreateContext();

        [DllImport("imm32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr ImmAssociateContext(IntPtr hWnd, IntPtr hImc);

        [DllImport("imm32.dll", CharSet = CharSet.Auto)]
        public static extern bool ImmDestroyContext(IntPtr hImc);

반응형