TranslateMessage() without a window?

This is a discussion on TranslateMessage() without a window? within the Windows Programming forums, part of the Platform Specific Boards category; hello all, I am ultimately trying to convert virtual key codes into ascii character codes; I am trying to make ...

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    24

    TranslateMessage() without a window?

    hello all,

    I am ultimately trying to convert virtual key codes into ascii character codes; I am trying to make use of the function TranslateMessage() as it appears to do exactly what I want. Although this funcion works fine when using a window, for some reason it wont work without one.

    My plan was to send 'dummy' WM_KEYDOWN/WM_KEYUP to my message loop thread with PostThreadMessage() and it would spit out WM_CHAR messages. However, it just refuses to create WM_CHAR messages no matter what I try. MSDN doesn't state that a window is required in order to use it, I just can't understand the problem.

    If anybody has any ideas at all why this isn't working I'd be very greatful. Thanks

    P.S. If anybody wants some sample source code to demonstrate the problem, I'll be happy to whip some up.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Try the MapVirtualKey function instead.

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    24
    I am currently using the MapVirtualKey function, however it doesn't handle the shift characters to make special characters. I would have to convert each ascii code (1 to !, 2 to ", etc) manually, and then do it differenetly for different keyboard layouts which just seems like far too much work.

    TranslateMessage() solves the problem that it automatically changes ascii codes dependant on whether shift is down, it also works with all keyboard layouts, therefore it's pretty much ideal, except I can't get it working without a window.

    If it turns out here my problem can't be solved, I'll simply have to have a window and not show it, but it seems highly inefficient and messy for what I am wanting.

    Thanks

  4. #4
    Registered User
    Join Date
    Aug 2009
    Posts
    1
    Was this problem solved? I'm in the same situation, but it appears that the function requires an input queue (the handle/id for which is the same as the thread which is hosting a window). I've resorted to creating a hidden window, is there any way to simulate this call via documented/undocumented API?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 09:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 03:33 PM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 01:34 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21