|
Jusef Marzbany wrote: if(plParam->IsBeingReleased)PostThreadMessageW(g_dwThreadID, WM_KEYDOWN, wParam, lParam);
else PostThreadMessageW(g_dwThreadID, WM_KEYUP, wParam, lParam);
Are these switched? I thought releasing a key meant keyup, not keydown.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I did as you, but it still doesn't work ...
Now it looks like this:
-----------------------
if(plParam->IsBeingReleased)PostThreadMessageW(g_dwThreadID, WM_KEYUP, wParam, lParam);
else PostThreadMessageW(g_dwThreadID, WM_KEYDOWN, wParam, lParam);
Help me PLS
|
|
|
|
|
Disclaimer: I'm only trying to help find potential problems
with the info given. Don't assume I know the solution - I don't.
Emulating system messages is always problematic.
What's happening in the debugger?
To start with, are your WM_KEY* messages actually getting to
the EXE's message loop?
Next, maybe take a look (using the debugger) at the sequence of
messages involved with a real keystroke. You're going to need
to emulate that exactly for this to work.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, I've mentioned it before ...
I recieved WM_KEYUP as well as WM_KEYDOWN in my message loop and I'm sure about that ...
The only remaining problem is TranslateMessage( ) ...
One would say It doesn't understand above messages any more! Where's Bill Gates?
|
|
|
|
|
Jusef Marzbany wrote: The only remaining problem is TranslateMessage() ...
Have you checked the return value from TranslateMessage() ?
Jusef Marzbany wrote: Where's Bill Gates?
He doesn't work full time at MS anymore, so he's probably doing charity work or something
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
Yes, I have, It returns 0 for me
|
|
|
|
|
What kind of output do you get doing something like this
in the EXE:
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
if (msg.message == WM_KEYDOWN || msg.message == WM_KEYUP)
{
if (msg.message == WM_KEYDOWN)
TRACE0("WM_KEYDOWN - ");
else
TRACE0("WM_KEYUP - ");
if (!TranslateMessage(&msg))
{
TRACE0("TranslateMessage() Failed!\n");
}
else
{
TRACE0("TranslateMessage() Succeeded!\n");
}
}
if(msg.message == WM_CHAR || msg.message == WM_DEADCHAR || msg.message == WM_SYSCHAR ||
msg.message == WM_SYSDEADCHAR)
{
TRACE0("WM_CHAR!\n");
}
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
See I press a key! according to your code (that's exactly what I did!), I got:
1- one WM_KEYDOWN notification
2- a message saying TranslateMessage() has failed
and then nothing more!
So:
1- where's WM_KEYUP?
2- Why TranslateMessage() has failed?
|
|
|
|
|
Why don't you try to go deeper with the debugger? For instance, whenever the TranslateMessage fails, check out the details of the MSG structure.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Jusef Marzbany wrote: 1- where's WM_KEYUP?
You stated:
"I recieved WM_KEYUP as well as WM_KEYDOWN in my
message loop and I'm sure about that ..."
So you weren't actually getting both the messages before?
As cPallini mentioned, you'll need to debug this.
You're trying to force messages that are system messages.
Unless you do it the exact way the system does, it's not
going to work. That's why I said it's problematic.
TranslateMessage could be failing because you're not emulating the
system messages properly.
Keyboard input was never meant for multiple targets on Windows.
Only the one window with keyboard focus should get the key messages.
You may want to try posting messages to a window instead of
a thread.
Tip: Don't use MessageBox in the message loop!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you, Great
Thank you masters!
|
|
|
|
|
Does PostThreadMessage() succeed? Is the g_dwThreadID identifier valid?
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
Yes, It is ...
As I mentioned before, everything went fine and I recieved WM_KEYDOWN and WM_KEYUP ...
But TranslateMessage( ) fails ...
|
|
|
|
|
Apologies; in that case Mark's advice seems a good way to go.
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
Hi all,
in my application i am using the GetRawInputDeviceInfo and included the winuser.h and windows.h but it is saying
GetRawInputDeviceInfo' : undeclared identifier
can anyone tell the reason for this issue?
Thanks in advance..
modified on Saturday, September 13, 2008 1:05 PM
|
|
|
|
|
Hi all,
inmy application i have used the message shwon in the following line :
ON_MESSAGE(WM_INPUT, OnInput)
I am getting the error "WM_INPUT' : undeclared identifier"
can anybody tell me wat this error is and how i need to solve this???
|
|
|
|
|
"Minimum operating systems Windows XP"
Do you have the appropriate symbols defined for OS version in your stdafx.h file? Make sure they are 0x0501 to ensure the xp specific symbols get defined during compilation. Make sure to do a "Rebuild Solution" or equivalent to prevent any false negatives.
|
|
|
|
|
can you tell me clearly how to do that?
|
|
|
|
|
Most newer VC++ IDE's will place some version defines at the appropriate place in your stdafx.h file to ensure the symbols for the version of windows or IE your targeting get defined. You mentioned that you are using VC++ 6.0 in another thread so you will need the February 2003 Platform SDK in place for Windows XP symbols. (How to get the Platform SDK and getting it installed are described elsewhere on this site).
To get the symbols defined, you need to define the correct version symbols on newer IDE's. Sometimes with the Platform SDK installed and the directories listed in the proper order, you sometimes get the symbols without needing to define the symbol. (This might be due to a default version getting defined). If you still don't get the symbols defined that you desire, you can always try defining the version symbols explicitly like newer IDE's do in the stdafx.h file (I would try putting just the WINVER in, then _WIN32_WINNT, and so on until you get the symbols you need)...
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER
#define WINVER 0x0501
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif
|
|
|
|
|
Did you include Winuser.h, Windows.h?
|
|
|
|
|
Hi all,
in my MFC application i want to use the message WM_INPUT but i am not able to see this in the classs wizard,can any one suggest me how to get that????
|
|
|
|
|
Which version of Visual C++ are you using?
|
|
|
|
|
|
Sometimes in VC++ 6.0 you can go to the "Class Wizard", "Class Info" tab, and mess with the "Message Filter" in the "Advanced Options" section to get some messages to appear but I think the WM_INPUT message will not show since the Visual C++ 6.0 IDE was built before XP came out. I would doubt the WM_INPUT would show up on newer IDE's but I can only check up to VC++ 2003 and so far I cannot get the wizard to show it.
You will likely need to add the handler manually but first you will need the appropriate symbols. Anything that says it requires XP will likely mean you will need the February 2003 SDK (or something close in date but not later since this was the last SDK to be officially compatible with VC++ 6.0) for the required symbols in a Visual C++ 6.0 environment. How to get the SDK used to be posted all over the place but Microsoft tends to make it difficult to find stuff after it's lifecycle is declared over. You might be able to define the symbols yourself without the SDK but that is really beyond the scope of your question.
I really liked VC++ 6.0 IDE but I must admit that you should probably move up to a newer IDE if you are going to try and use functionality introduced with Windows XP. It is very painful to use VC++ 6.0 with newer features even with the Platform SDK installed.
I hope that helps.
|
|
|
|
|
Hi all,
I am new to the concepts on vc++, in my application i want to get the external hid device name connected to the system.
can anybody suggest me the right approach for doing this???
|
|
|
|