Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When developing for a tablet PC, how do I determine if the user clicked a mouse or a pen?

Tags:

How do I check if the user clicked with a mouse or with a pen stylus on a C# control.

For eg. If the user clicks a text box with a pen button then I want an input panel to pop up but if he clicks with a mouse then it shouldn't. So how do I check whether he was using a mouse or a pen?

Edit: Using Windows Forms not WPF

like image 341
Anirudh Saraf Avatar asked Apr 17 '09 02:04

Anirudh Saraf


1 Answers

I wrote an article for MSDN that never got published, I guess because Tablet PC development fizzled out by the time I got it to them. But it described how to do this. Long story short, you'll want the GetMessageExtraInfo API. Here's the definitions:

// [DllImport( "user32.dll" )]
// private static extern uint GetMessageExtraInfo( );

uint extra = GetMessageExtraInfo();
bool isPen = ( ( extra &  0xFFFFFF00 ) == 0xFF515700 );

Email me at my first name at Einstein Tech dot net if you want me to send you the article.

like image 168
Josh Avatar answered Oct 04 '22 18:10

Josh