| Scalabium Software | |
| Knowledge for your independence'. | |
|  Home  Delphi and C++Builder
        tips | 
| #174: How can I found out if a computer screen is touch or not? | 
| 
 | I want to post the code for easy way to find out if a computer screen is touch (such as, for example, a Surface).
Also with this function you may check if pen (integrated or external) is active or device supports the multi input. type
  TInputDigitizer = (idIntegratedTouch, idExternalTouch, idIntegratedPen, idExternalPen, idMultiInput);
  TInputDigitizerSet = set of TInputDigitizer;
function GetInputDigitizerPresent: TInputDigitizerSet;
const
  SM_DIGITIZER = 94;
  NID_INTEGRATED_TOUCH = $01;
  NID_EXTERNAL_TOUCH   = $02;
  NID_INTEGRATED_PEN   = $04;
  NID_EXTERNAL_PEN     = $08;
  NID_MULTI_INPUT      = $40;
  NID_READY            = $80;
var
  Value: Integer;
begin
  Result := [];
  Value := GetSystemMetrics(SM_DIGITIZER);
  if ((Value and NID_READY) = NID_READY) then
  begin
    if ((Value and NID_INTEGRATED_TOUCH) = NID_INTEGRATED_TOUCH) then
      Result := Result + [idIntegratedTouch];
    if ((Value and NID_EXTERNAL_TOUCH) = NID_EXTERNAL_TOUCH) then
      Result := Result + [idExternalTouch];
    if ((Value and NID_INTEGRATED_PEN) = NID_INTEGRATED_PEN) then
      Result := Result + [idIntegratedPen];
    if ((Value and NID_EXTERNAL_PEN) = NID_EXTERNAL_PEN) then
      Result := Result + [idExternalPen];
    if ((Value and NID_MULTI_INPUT) = NID_MULTI_INPUT) then
      Result := Result + [idMultiInput];
  end;
end;
The sample code:var
  id: TInputDigitizerSet;
begin
  id := GetInputDigitizerPresent();
  if (id <> []) then
    ShowMessage('Computer screen supports the touch')
  else
    ShowMessage('Computer screen do not support the touch')
end;
 | 
 | 
|       | Copyright© 1998-2025, Scalabium
        Software. All rights reserved. |