
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Tracking and Responding to the Mouse
|
535
if ((state & KF_UP) == KF_UP)
{
// Is the key up?
if ((lparam & KB_TRANSITION_FLAG) == KB_TRANSITION_FLAG)
{
// Is this the V key?
if (wparam == VK_V)
{
// Handle AppMenu-v key combination here...
textBox1.Text += "AppMenu-v action caught" +
Environment.NewLine;
}
}
}
}
return (CallNextHookEx(hookHandle, code, wparam, lparam));
}
This callback gets the state of the Menu key and determines whether it is depressed
((state & KF_UP) == KF_UP). If it is depressed, the V key is checked to see if it is being
released
((lparam & KB_TRANSITION_FLAG) == KB_TRANSITION_FLAG ). If these condi-
tions are true, a message is displayed. (Of course, you could add your own code here
to do something more interesting.)
See Also
See Recipe 9.11; see Subclassing & Hooking with Visual Basic (O’Reilly); and see the
“Delegate Class” and “Hooks” topics in the MSDN documentation.
9.11 Tracking and Responding to the Mouse
Problem
Many new mice have more than just a left and right button. Nowadays, mice come
with several additional buttons and a mouse wheel. You need to allow your applica-
tion to take advantage of these new mice features. Additionally, you might need to
know the mouse’s current location on a particular window, whether it is on the cli-
ent area of the window ...