Kentzo
Kentzo

Reputation: 3993

How can I recognize if window is being drawn on a touchable screen?

I would like to have two different layouts for my app: one for regular desktop and one for a touchable device.

How can I query if screen my app is being drawn on supports multitouch?

Upvotes: 0

Views: 69

Answers (2)

IInspectable
IInspectable

Reputation: 51506

To my knowledge, there is no direct way to query for input capabilities based on the display(s) a window is displayed on. You can, however, query the system for touch input capabilities.

On Windows XP and Windows Vista you can ask the system, whether a touch digitizer is attached to the system. It doesn't report, whether is supports multi-touch, though. The API to use is GetSystemMetrics:

bool TouchInputAvailable() {
    return ( ::GetSystemMetrics( SM_TABLETPC ) != 0 );
}

For systems running Windows 7 or Windows Server 2008 R2 (and above), the OS reports multi-touch capabilities as well:

bool MultiTouchAvailable() {
    int value = ::GetSystemMetrics( SM_DIGITIZER );
    return ( ( value & ( NID_MULTI_INPUT | NID_READY ) )
                    == ( NID_MULTI_INPUT | NID_READY ) );
}

Upvotes: 1

Kevin Condon
Kevin Condon

Reputation: 1738

Try calling IsTouchWindow, which is defined through Winuser.h.

Upvotes: 0

Related Questions