Click to See Complete Forum and Search --> : hALT! PostMessage Question
Joey_k29
Dec 13th, 2001, 09:36 AM
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/default.asp?url=/library/en-us/wcesdkr4/htm/_wcesdk_win32_wm_keydown.asp for the article on wm_keydown. Thank you very much.
Joe
CornedBee
Dec 13th, 2001, 10:31 AM
/* 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.
Joey_k29
Dec 13th, 2001, 10:40 AM
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
CornedBee
Dec 14th, 2001, 06:37 AM
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:
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);
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.