WM_KEYDOWN and SendMessage

This is a discussion on WM_KEYDOWN and SendMessage within the Windows Programming forums, part of the Platform Specific Boards category; Hello, I have got a problem with WM_KEYDOWN and SendMessage(). I'm trying to send an upper case 't' ('T') to ...

  1. #1
    Unregistered
    Guest

    Question WM_KEYDOWN and SendMessage

    Hello,

    I have got a problem with WM_KEYDOWN and SendMessage(). I'm trying to send an upper case 't' ('T') to an edit field using the following function call:
    SendMessage(hwnd, WM_KEYDOWN, VkKeyScan('T'), NULL)

    The problem now is, that the target input field only prints a lower case 't'.
    Question: How can I get the input field to print an upper case 't' ('T') using SendMessage() and WM_KEYDOWN? I thought of sending a WM_KEYDOWN message equal to a SHIFT-T keystroke, but I don't know how to do that. Got any ideas?

    Thanks in advance for your answers

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Send a WM_KEYDOWN for the shift key. Then the message for the t key. Then, the WM_KEYUP for the t key. Then for the shift key.

  3. #3
    Unregistered
    Guest
    Ok, sorry to ask, but how exactly do I do this?
    I tried...

    Code:
    SendMessage(hwnd, WM_KEYDOWN, VK_SHIFT, NULL);
    SendMessage(hwnd, WM_KEYDOWN, VK_T, NULL);
    SendMessage(hwnd, WM_KEYUP, VK_T, NULL);
    SendMessage(hwnd, WM_KEYUP, VK_SHIFT, NULL);
    and...

    Code:
    SendMessage(hwnd, WM_KEYDOWN, VK_SHIFT, MAKELPARAM(MAKEWORD(1,0), MAKEWORD(0, 64)));
    SendMessage(hwnd, WM_KEYDOWN, VK_T, MAKELPARAM(MAKEWORD(1,0), MAKEWORD(0, 64)));
    SendMessage(hwnd, WM_KEYUP, VK_T, NULL);
    SendMessage(hwnd, WM_KEYUP, VK_SHIFT, NULL);
    Both didn't work. VK_T is defined as 0x54 and VK_SHIFT as 0x10.

  4. #4
    Unregistered
    Guest
    Forgot to mention, the last two tries still produced a lower case 't'.

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    haven't tried this myself, but have you tried WM_CHAR instead?

    Maybe you need to some some of the flags in lParam when sending the WM_KEY* messsages??

    Just a quick thought

    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

Popular pages Recent additions subscribe to a feed

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