BeforeClick (or MouseClick) determine if a specific key is pressed?

OOT
03-27-2008, 09:50 AM
Hey everyone. I'm using Mappoint 2006 and Visual Basic 2005. What I'm trying to determine is if there is a way, when a user clicks a pushpin, if a certain key is already depressed (pressed, selected?). Mappoint doesn't have (as far as I can tell) a KeyPress event. I'm not exactly sure if this is possible and definitely not sure how to do it if it is so I'm hoping somebody here can lend a helping hand ... please please please.

So, let's say if a user clicks on a Pushpin, the first thing I want to know is if the Ctrl key is currently depressed? If yes, then do something. If not, do what Mappoint normally does.

Is this possible?

Thank you in advance for any and all help that you can give. It is very much appreciated.

aroberts
03-27-2008, 12:00 PM
You could use this API function to examine the key state:

SHORT GetKeyState(int nVirtKey) // virtual-key code;

Where nVirtKey is VK_SHIFT (Shift Key), VK_CONTROL (Ctrl Key), and VK_MENU (Alt Key)

If the function succeeds, the return value specifies the status of the given virtual key. If the high-order bit is 1, the key is down; otherwise, it is up. If the low-order bit is 1, the key is toggled.

The key status returned from this function changes as a given thread reads key messages from its message queue. The status does not reflect the interrupt-level state associated with the hardware. Use the GetAsyncKeyState function (same syntax) to retrieve that information.

Wilfried
03-31-2008, 06:10 AM
Hi,

there is a shift property in the event handler's argument. You can set there a bitmask to check if shift, alt, or ctrl (or combination) is pressed.

 
Web mp2kmag.com
mapforums.com