how to detect if user has a touchscreen (1 Viewer)

CJ_London

Super Moderator
Staff member
Local time
Today, 10:53
Joined
Feb 19, 2013
Messages
16,553
I have a client where a couple of (senior management) users have now got touchscreens attached to their laptops. I already have a facility for users to personalise the look of their forms in terms of colours and fonts (blended with the security options of which controls/forms etc are visible). The system is distributed as accde 2010 runtime.

I added a font size option which enlarges visible controls to cater for it, but it is intended as an occasional change (i.e. user goes into setup and configures the properties). However one user regularly works away without their touchscreen so they have to go in to the properties and reduce the font size and then when back in the office, enlarge it again.

I suggested just configuring everything to the larger font, but the non touchscreen users don't like it since they see less on the screen.

It is not a major hassle for the user but I thought it would be nice if I could detect if a touchscreen was attached and it would automatically adjust the font size.

So can anyone point me in the direction of some code/api to detect if a touchscreen is attached? What would be really cool is if the code could detect based on the monitor the form is on, but I suspect that is a step too far!
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:53
Joined
Feb 19, 2013
Messages
16,553
Hi James,

I do already reference GetSystemMetrics for things like heights and widths but took another look, it has a mousepresent value, the problem is the user connects his mouse, even if he doesn't use it for this application (he will have say outlook open on the laptop, this app on the touchscreen)

Thanks for the suggestion
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:53
Joined
Feb 19, 2013
Messages
16,553

CJ_London

Super Moderator
Staff member
Local time
Today, 10:53
Joined
Feb 19, 2013
Messages
16,553
that did the trick

Code:
 Const SM_DIGITIZER = 94
 Debug.Print GetSystemMetrics(SM_DIGITIZER)
returns 0 if touchscreen is not available
and 193 if it is

My mistake was thinking about the screen, when it is actually an input device

Many thanks
 

isladogs

MVP / VIP
Local time
Today, 10:53
Joined
Jan 14, 2017
Messages
18,186
that did the trick

Code:
 Const SM_DIGITIZER = 94
 Debug.Print GetSystemMetrics(SM_DIGITIZER)
returns 0 if touchscreen is not available
and 193 if it is

I know this is ancient but the above isn't quite true. It will return a non zero value if touchscreen is available. The screenshot is from my System Metrics utility on my Windows tablet where the value is 2895



If you want to find out all your system metrics values, the utility is in sample databases as well as at http://www.mendipdatasystems.co.uk/system-metrics/4594428381
 

Attachments

  • Capture.PNG
    Capture.PNG
    30.9 KB · Views: 284

Users who are viewing this thread

Top Bottom