Results 1 to 18 of 18

Thread: [RESOLVED] How to get Unicode char on IME window in VB6?

Threaded View

  1. #13

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: [RESOLVED] How to get Unicode char on IME window in VB6?

    Quote Originally Posted by Tanner_H View Post
    Thanks for clarifying, Jonney. I also tried the sample project you provided, and even after trying many things, I couldn't find a way to successfully trap WM_IME_KEYDOWN. I have no idea why that message isn't being captured. I think LaVolpe's suggestion in your other thread, to just use a temporary TextBoxW, is the best solution.

    For what it's worth, I did find some bugs in your ImmGetCompositionString code. Change the declaration to this:

    Code:
    Public Declare Function ImmGetCompositionStringW Lib "imm32.dll" (ByVal himc As Long, ByVal dw As Long, ByVal lpv As Long, ByVal dw2 As Long) As Long
    Whenever you pass a pointer directly to an API (StrPtr, VarPtr), you need to change the API parameter to be ByVal instead of ByRef.

    Another bug is this: when you pass 0 as the length to ImmGetCompositionString, so it will return the size of the string buffer, the buffer size is returned in bytes, not characters, and it doesn't include the null-terminating character. Because of this, you might find it easier to pass the function a byte array instead of a VB string, then convert the byte array after the API has filled it.

    However, even with these changes, I still don't get useful results from the function. It could possibly be an ANSI/Unicode issue, or maybe there is another bug I haven't caught...?
    Thank you for follow-up.
    I tried many definitions for ImmGetCompositionStringW API but always return 0. The problem is that I can't intercept most IME Message except 3: WM_IME_SETCONTEXT,WM_IME_STARTCOMPOSITION and WM_IME_CHAR.

    I do believe it can be done, since there're thousand free INPUT methods in Asia except MS keyboard PinYin.

    Wondering I haven't seen any stuff in VB6. vbaccelerator and cyberActivex don't have such stuff.

    If you got time (don't spend much), you can do some research since you have much more knowledge on Hook... than me.

    I believe Github has many projects. e.g. https://github.com/trmmy/zenisynth/b...zs_x86hook.cpp

    Search "input methods" or "IME", we can get many results.

    Edited:
    Private Declare Function ImmGetDefaultIMEWnd Lib "imm32.dll" (ByVal hwnd As Long) As Long

    can return the hWnd of IME window.
    Last edited by Jonney; Jan 21st, 2015 at 07:51 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width