My application runs on a desktop PC and / or tablet. For the latter, however, I see that I have to provide an on-screen keyboard - this is not difficult with the supplied TTouchKeyboard. My question is, how do I know if a touch is available or not? I found some sample code that calls WinAPi calls in GetSystemMetrics:
function GetTouchCapabilities : TTouchCapabilities; var ADigitizer : integer; begin result := []; // First check if the system is a TabletPC if GetSystemMetrics(SM_TABLETPC) <> 0 then begin include(result,tcTabletPC); if CheckWin32Version(6,1) then begin // If Windows 7, then we can do additional tests on input type ADigitizer := GetSystemMetrics(SM_DIGITIZER); if ((ADigitizer and NID_INTEGRATED_TOUCH) <> 0) then include(result,tcIntTouch); if ((ADigitizer and NID_EXTERNAL_TOUCH) <> 0) then include(result,tcExtTouch); if ((ADigitizer and NID_INTEGRATED_PEN) <> 0) then include(result,tcIntPen); if ((ADigitizer and NID_EXTERNAL_PEN) <> 0) then include(result,tcExtPen); if ((ADigitizer and NID_MULTI_INPUT) <> 0) then include(result,tcMultiTouch); if ((ADigitizer and NID_READY) <> 0) then include(result,tcReady); end else begin // If not Windows7 and TabletPC detected, we asume that it ready include(result,tcReady); end; end; end;
There is also a Microsoft Tablet PC definition here .
Then I searched the source of RTL and Delphi to try to find the routines that more directly gave me this information in the same way that Delphi wraps OS version information, but I do not see it (although it may be that I just donβt know what to look for !). Is the above code style the best way to detect sensory capabilities? Or am I missing something more obvious?
source share