Results 1 to 17 of 17

Thread: How to get unicode on KeyPress event?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    How to get unicode on KeyPress event?

    Private Sub UserControl_KeyPress(KeyAscii As Integer)

    I found that the parameter already is ANSI value, not UNICODE.

    how to get the unicode character pressed to avoid to lose information in the convertion?.

    Or what will happen if it is used on a chinese machine, etc. it will bring the real unicode value?

    I tryed the "á" and that variable already has the ANSI value, not the 16bits unicode version of it.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: How to get unicode on KeyPress event?

    You may need to subclass in order to intercept and translate WM_UNICHAR messages.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: How to get unicode on KeyPress event?

    Quote Originally Posted by dilettante View Post
    You may need to subclass in order to intercept and translate WM_UNICHAR messages.
    subclass what? the usercontrol container or the parent form?

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: How to get unicode on KeyPress event?

    Subclass the window you want to handle these characters for. If these are characters to the UserControl then subclass the UserControl.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: How to get unicode on KeyPress event?

    Wait, VB6 is capable in native controls to let the user write in japanese and so.? right?...

    So, if doing a custom usercontrol, only to subclass the usercontrol, right?

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: How to get unicode on KeyPress event?

    https://stackoverflow.com/questions/...si-window-uc-o

    It will be lot harded than I though, the subclass won't work.

    Because the VB6 forms are marked as ANSI, only ansi characters will reach the events.

    Also don't know if usercontrol.print is able to print chinese/japanese, if the windows is marked as ANSI.

    So, now that I have all my code in unicode.... found VB6 don't handle unicode interface. pffffffffffffffffffffffffffffff

  7. #7
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: How to get unicode on KeyPress event?

    Also notice that most of the information on VB6 on the interwebs is outdated.

    Maybe others will chime in with links to proper threads here on VBForums the topic has been discussed, resolved, later fixed, rediscovered, etc.

    cheers,
    </wqw>

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: How to get unicode on KeyPress event?

    Quote Originally Posted by wqweto View Post
    Also notice that most of the information on VB6 on the interwebs is outdated.

    Maybe others will chime in with links to proper threads here on VBForums the topic has been discussed, resolved, later fixed, rediscovered, etc.

    cheers,
    </wqw>
    oh, you mean there is different about vb6 sp4 (those old threads) vs vb6 sp6?

  9. #9
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: How to get unicode on KeyPress event?

    but it is all about the keyboard, how can it be unicode? do we have unicode keyboards?

  10. #10
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: How to get unicode on KeyPress event?

    Why Baka, don't you do all your typing by holding down the alt key and using the keypad?

    EDIT1: Or didn't you get one of these with the rest of us?

    Name:  chinese.jpg
Views: 561
Size:  46.2 KB
    Last edited by Elroy; Jun 6th, 2018 at 10:49 AM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: How to get unicode on KeyPress event?

    well, I consider, it is time to shift to another language's version, .NET.

    I don't care about usercontrol's properybag because I don't even use it for storing text, it is loaded from a now unicode text file (skin scripting).

    but, if the native textbox and others native controls is unable to edit, show, unicode characters, I don't want to change the class the about 600+ textboxes in 50+ forms, it will be a marathonic work.

    And what more it requires?.


    UNSOLVABLE PROBLEMS: and I don't get done the winsock overflow problem, the famous "this operation will block, in an async socket" problem, seem simply the ammount of traffic overflows the sockets internals, overall observed when just reset the server, and for when it is up again , there is 30+ clients PCs trying to connect... , the listening socket for connections is BLOWN . Ofcourse I did the code smarter enough, if the socket(0) gets an error/close event, the routine to set up it for listing again works. Works most of the times, but sometime it crashs ALL SOCKETs , ALL ARRAYs, at the same time, and then don't recover from that anymore, it is like, from 20 error , 1 is impossible to recover. Don't matther it close/unload the sockets, and then recreate it from scratchs, the sockets fails to listening, with the same error BLOCKING, on non blocking. And it already has the code to care about buffering the output, use the Send_Complete method, do it all in Byte arrays, everything fine...., small packages every time, not so small, like 4K is fine for LAN usage, etc.

    Stadistically a customer receive a massive drop, each month. Seeing logs, it is about 1 massive drom each 10 to 20 times the socket error is logged.

    It is also sensitive about what more is doing the server, if it is dedicated or shared server. So, the BLOCKING/ socket is timming sensitive.

    Before with c-socketmaster was not that problem, but csocket has another issues with, data execute protection, and performance issues, it is not the faster thing.


    Anyway, two reasons to abandon VB6. God I hate .Net, I resist the switch.

  12. #12
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,374

    Re: How to get unicode on KeyPress event?

    Quote Originally Posted by flyguille View Post
    but, if the native textbox and others native controls is unable to edit, show, unicode characters, I don't want to change the class the about 600+ textboxes in 50+ forms, it will be a marathonic work.

    And what more it requires?.
    You could replace all intrinsic and common controls with the VBCCR controls. They are unicode at display and input (e.g KeyPress)
    It come in two flavors: 1. As UserControls to include within an Std-EXE project. 2. As OCX.

    http://www.vbforums.com/showthread.p...mmon-controls)

  13. #13
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: How to get unicode on KeyPress event?

    600+ textboxes in 50+ forms
    You should be able to do this in just a few seconds.
    Use NotePad++ to replace in all Form files "VB.TextBox" with "VBCCR15.TextBoxW" (without the quotes).
    You will also need to add VBCCR15.Ocx to your Vbp file.

    Name:  Find in Files.png
Views: 908
Size:  15.2 KB
    Last edited by DrUnicode; Jun 6th, 2018 at 03:21 PM. Reason: Added Screenshot

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: How to get unicode on KeyPress event?

    Quote Originally Posted by DrUnicode View Post
    You should be able to do this in just a few seconds.
    Use NotePad++ to replace in all Form files "VB.TextBox" with "VBCCR15.TextBoxW" (without the quotes).
    You will also need to add VBCCR15.Ocx to your Vbp file.
    Interesting, thanks very much SIR!.

  15. #15
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: How to get unicode on KeyPress event?

    Quote Originally Posted by flyguille View Post
    https://stackoverflow.com/questions/...si-window-uc-o

    It will be lot harded than I though, the subclass won't work.

    Because the VB6 forms are marked as ANSI, only ansi characters will reach the events.

    Also don't know if usercontrol.print is able to print chinese/japanese, if the windows is marked as ANSI.

    So, now that I have all my code in unicode.... found VB6 don't handle unicode interface. pffffffffffffffffffffffffffffff
    You should be able to mark the UserControl as Unicode with subclassing as well by responding to the WM_NOTIFYFORMAT message with NFR_UNICODE.

  16. #16
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: How to get unicode on KeyPress event?

    Right? Krool and DrUnicode already solved this issue in their controls.
    You can look at the code, to see Krool did it, but it looks like he just caches the unicode char on WM_KEYDOWN/UP.
    and then resets it in WM_CHAR.

  17. #17
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,899

    Re: How to get unicode on KeyPress event?

    Well hey dudes, I have a better way of doing this. you just use the Fom_KeyPress() handler that comes within Forms and UserControls in VB6 and VBA objects. then here it goes...
    Code:
    Form_KeyPress(KeyAscii as blah blah)
    Text1.Text = KeyAscii
    End Sub
    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Event's Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Bar | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University |

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

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