Archived

This topic is now archived and is closed to further replies.

Lord Hen

Pocket PC GetAsyncKeyState C#.Net

Recommended Posts

Hi.. I''ve been learning C#.net for use on a Pocket PC 2002...(uses .net compact framework) On This Site he talks about using GetAsyncKeyState for detecting arrowkeys... Its declared as:
[DllImport("coredll.dll")] 
private static extern int GetAsyncKeyState(int vkey);
 
But Im not able to get it to detect if any of the hardware arrowkeys are down, I believe that Left is 37, Up is 38, Right is 39, and Down is 40...because thats what his enum had.
//in a loop
if (GetAsyncKeyState(38) != 0)
{
   //This is not reached when i press up...why!?
}
 
This is what Im apparently supposed to do, but it doesnt work...argh Can anyone help with this? Thanks, Lord Hen

Share this post


Link to post
Share on other sites
Could it be that Im using the VS.NET 2003 Pocket PC Emulator?

I wont be getting my pocket pc for a few days(shipping...argh)...so I cant exactly test it on a real device.

If anyone would try this out on both the emulator and the actual device, it would be greatly appreciated =)

psuedocode of what im doing:

//loop
if (GetAsyncKeyState(left) == Pressed)
//notify of keypress: msgbox, label, etc
Application.DoEvents();
//end loop


Thanks,
Lord Hen



Edit: OK, I got my pocket pc and getasynckeystate DOESNT work on the emulator, but it works like a charm on the actual device. Im sorry, I should have waited until I actually got it.

[edited by - Lord Hen on August 6, 2003 12:20:15 AM]

Share this post


Link to post
Share on other sites