Elo TouchSystems MonitorMouse FOR WINDOWS NT Version 2.0 manual Appendix B - Programming Options

Models: MonitorMouse FOR WINDOWS NT Version 2.0

1 35
Download 35 pages 10.31 Kb
Page 33
Image 33
28Appendix B - Programming Options

28Appendix B - Programming Options

The following example code demonstrates how to obtain Z data. For a complete example, see the included source code for ZAXIS.EXE.

#include "mmioctl.h"

HANDLE hndFile;

// Win32 handle of "MMDev" device

LONG

IoctlCode;

// Function to perform

ULONG

DataLength;

// Output buffer data length

DWORD

ReturnedLength;

// Actual number of bytes returned

LONG

IOBuffer;

// Input/output system buffer

BOOL

IoctlResult;

// Result of operation

//

// Open Win32 touchscreen device(MMDev)

//

hndFile = CreateFile( "\\\\.\\MMDev",

GENERIC_READ, FILE_SHARE_READ, NULL,

OPEN_EXISTING, 0,

NULL

// Open the device "MMDev"

);

if (hndFile == INVALID_HANDLE_VALUE) {// Was the device opened? MessageBox(NULL, "Unable to open touchscreen",

"Driver Loaded?", MB_OK);

return(0);

}

// See if controller supports Z before going any further

IOBuffer = 0;

IoctlCode = IOCTL_MM_ZAXIS_SUPPORT;

IoctlResult = 0;

DataLength = 4;

IoctlResult = DeviceIoControl(

hndFile,

 

// Handle to device

IoctlCode,

 

// IO Control code for

Read

NULL,

 

// We don't need input

data

0,

 

// No input buffer required, NULL bytes

&IOBuffer,

 

// Buffer from driver.

 

DataLength,

 

// Length of buffer in

bytes.

&ReturnedLength,

// Bytes placed in DataBuffer.

NULL

 

// NULL means wait till op. completes.

);

 

 

 

if (!IoctlResult)

// No z

 

 

MessageBox(NULL, "This controller does not support Z reporting capabilities",

"NO Z", MB_OK MB_ICONEXCLAMATION);

//

//Call the driver to get Z values

IOBuffer = 0;

IoctlResult = 0;

DataLength = sizeof(LONG);

Page 33
Image 33
Elo TouchSystems MonitorMouse FOR WINDOWS NT Version 2.0 manual Appendix B - Programming Options