|
-
Dec 13th, 2001, 10:36 AM
#1
Thread Starter
Hyperactive Member
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
-
Dec 13th, 2001, 11:31 AM
#2
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.
-
Dec 13th, 2001, 11:40 AM
#3
Thread Starter
Hyperactive Member
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
-
Dec 14th, 2001, 07:37 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|