Thread: WM_KEYDOWN and SendMessage

  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,138
    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