Results 1 to 4 of 4

Thread: hALT! PostMessage Question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352

    hALT! PostMessage Question

    Okay, I have one simple problem. I am trying to use PostMessage with wm_keydown. I want to be able to send the alt key. Please don't refer me to the msdn article. I do not know how to construct the parameter so that I can turn the 29 bit to 1. If someone can please give me the code that does this, I would be grateful. Go to http://msdn.microsoft.com/library/de...wm_keydown.asp for the article on wm_keydown. Thank you very much.

    Joe

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Code:
    /* C-syntax */
    #define SETBIT(num, bit) \
        ((num) |= (1 << (bit)))   // could also be bit - 1, not sure, try
    
    #define RESETBIT(num, bit) \
        ((num) &= (^(1 << (bit))))   // could also be bit - 1, not sure, try
    
    
    // C++ syntax
    template<class T>
    inline void SETBIT(T& num, int bit)
    {
        num |= 1 << bit;    // same here
    }
    
    template<class T>
    inline void RESETBIT(T& num, int bit)
    {
        num &= ^(1 << bit);    // same here
    }
    That should work.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352

    Okay but......

    what does the actual Postmessage look like??? I am not very well acquainted with c++ so I am not sure what that code means. How would I make the call? Thank you for the help.

    Joe

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You would declare a LPARAM variable, set the things you want, set bit 29 by using my functions/macros and then do a PostMessage supplying the LPARAM as parameter:
    Code:
    int vKey = VK_A;
    LPARAM lParam = repCount; // the amount of key repeats that occurred until this message was retrieved
    lParam |= (scanCode << 16);  // the keyboard scan code. Most apps don't care about this, so you can set it to 0
    SETBIT(lParam, 29);  // alt is pressed
    RESETBIT(lParam, 30); // the key was not already pressed before this message was sent
    RESETBIT(lParam, 31); // the key is pressed, not released
    
    PostMessage(hwndDestination, WM_KEYDOWN, (WPARAM)vKey, lParam);
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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