Scalabium Software

SMExport advertising
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;


Published: March 4, 2023

See also
 
DBExport tools
SMReport
Excel Reader (dll)
SMMsg suite
Clarion to Text converter
Paradox Password Recovery
MAPIMail
SMExport suite
dBase Viewer
Excel Web-stream
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2024, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMReport Autogenerated