Print Page | Close Window

Unicode keyboard input

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=17177
Printed Date: 30 November 2024 at 10:04am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Unicode keyboard input
Posted By: dbenito
Subject: Unicode keyboard input
Date Posted: 31 August 2010 at 1:25pm
I'm struggling with a rather obscure problem: when hosted on VB6 forms, COM controls that host Unicode windows (e.g. created by calling CreateWindowExW) receive incorrect information in WM_CHAR messages for certain Unicode characters (for example, if you try to enter Tamil characters you always get sent question marks instead); funnily enough, if the same control is hosted in a Unicode application (such as IE), the WM_CHAR messages come through just fine. I suspect it has something to do with VB6 calling the ANSI version of TranslateMessage in the message loop.
 
Any, I finally figured out a way of getting around this, which is to subclass the Unicode window, storing the keycode sent in WM_KEYDOWN and then constructing the corresponding Unicode character in WM_CHAR message (by calling ToUnicodeEx in certain circumstances, etc.), and it works fine in my own controls.
 
Unfortunately, the CodeJock Suite Controls don't do any such handling, and it would be a pain to have to subclass each one individually (particularly since they already use subclasses internally, and I'd rather not interfere with that). So I though a solution might be to install a thread-wide WH_GETMESSAGE hook and do the same kind of processing. The weird this is that, when I check the data sent with the WM_CHAR message intercepted by my hook, the Unicode characters are always set correctly. However, whether I return from the hook immediately or I call the next hook, the control (in this case a CodeJock FlatEdit control, which internally uses a standard Windows Edit control) eventually seems to receive a WM_CHAR with the wrong stuff (character code 63, as usual).
 
Does anyone have any experience with entering complex script text (particularly for the new Unicode-only locales that were added in Windows XP, such as Tamil or Gujarati?) into CodeJock Suite controls hosted in VB6?



Replies:
Posted By: dbenito
Date Posted: 01 September 2010 at 6:49am
I realize most people probably won't be interested in this, but I'll post my solution just in case:
 
What I ended up doing was a combination of hooking and subclassing (using the ComCtl32 subclassing functions, which are only supported on Windows XP or greater, but are very safe and don't seem to interfere with existing subclasses). First I install a WH_CALLWNDPROC hook (for the thread in which my VB6 UI is running) to intercept all WM_CREATE events, and I basically subclass any new window that gets created (making sure to remove the subclass when WM_DESTROY gets called). I also install a WH_GETMESSAGE hook (again, only for my UI thread), and whenever it gets a WM_CHAR message, it stores the hWnd and wParam values (which always seem to include the correct Unicode char). Then, in the subclass window proc, when I process a WM_CHAR message I compare the hWnd values and, if they match, I replace the incorrect wParam (which VB6 has probably messed up somehow) and replace it with the value I had stored.
 
If anybody is having trouble with complex script input with CodeJock controls in VB6, I'll be glad to send them code snippets.


Posted By: surfer_del
Date Posted: 26 August 2011 at 7:45am
thanx for your suggestion i am facing the same problem. whenever i try to input with ime (google or other) i get ?????. i am using vb6 with sp6. please send the code to amaanshiekh@yahoo.com

i hope you will reply

with best wishes
amaan


-------------
surfer


Posted By: TomasS
Date Posted: 09 January 2012 at 9:08am
I had similar problems in vb6. I tried entering unicode text in chinese, korean and some other languages, but they all just turned into question marks in the CJ controls. Just like in the native controls. But after setting keypreview=false on the form it worked fine.



-------------
Xtreme SuitePro (ActiveX) version 17.3.0, 16.3.1
Windows 10 64-bit
Visual Basic 6.0


Posted By: ngyntom
Date Posted: 14 February 2012 at 3:42am
I tried entering unicode text in vietnam, flatedit display ??. i changed keypreview but not show, can u help me?

i'm using 
-Codejock.Controls.Unicode.v15.0.1.ocx
-vb6sp6


Posted By: surfer_del
Date Posted: 21 February 2012 at 12:29am
Smile
hi i request you to send the code please. but didnt replied .
if you have that please provide the community.
 
thank you,
 


-------------
surfer



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net