# Appendix C
Enable/Disable Sample Code

// EnableDisable.cpp : Defines the entry point for the sample EnableDisable

// touch application.

//

// Copyright(c) 2004 Elo TouchSystems, Inc., all rights reserved.

//

// Sample application to Enable/Disable touch using Elo SDK.

// Include EloPubIf.lib in the linker dependencies.

// Files EloPubIf.lib, EloInterface.h, EloErrorCodes.h can be found in

// \Program Files\EloTouchSystems folder.

// This program can be compiled using Microsoft Visual Studio 7.0 or 6.0

//

// Usage: EnableDisableSample -[e/d] -n:<mon num>[,<mon num>...]

// -e : Enable touch

// -d : Disable Touch

// -n:<mon num>[,<mon num>...] : Monitors to enable or disable

// -----------------------------------------------------------------------------

#include <windows.h>

#include <stdio.h>

#include <tchar.h>

#include <stdlib.h>

#include "EloInterface.h"

#include "EloErrorCodes.h"

// -----------------------------------------------------------------------------

// Globals

// -----------------------------------------------------------------------------

BOOL bEnable = TRUE;

int dwMonParamCnt=0;

DWORD dwMonParam[MAX_SUPPORTED_SCR] ;

void ProcessCmdLine( int argc, char** argv) ;

// -----------------------------------------------------------------------------

// main entry point

int _tmain(int argc, char** argv)

{

DWORD dwEnumMon[MAX_SUPPORTED_SCR] ;

int iScrCnt, iRet ;

if( argc < 3 )

{

printf( "Usage: EloEnableDisableSample -[e/d] \

-[n:<mon num>,[,<mon num>...]]\n\n \

-e \t\t\t\t: Enable touch\n \

-d \t\t\t\t: Disable Touch\n \

-n:<mon num>[,<mon num>...] \

\t: Monitors to enable or disable \n" ) ;

return EloFailure ;

}

ZeroMemory( dwEnumMon, MAX_SUPPORTED_SCR ) ;

ZeroMemory( dwMonParam, MAX_SUPPORTED_SCR ) ;

// Get the list of all Elo Serial & USB screen and monitor association

iRet = EloGetScreenInfo(dwEnumMon,iScrCnt) ;

if(iRet != EloSuccess )

{

printf( "Error Code = %d \n", iRet ) ;

return EloFailure;

}

else

if(iScrCnt<0)

{

printf( "No Elo touchscreens found\n" ) ;

return EloFailure;

}

// Process Commandline

ProcessCmdLine( argc, argv ) ;

// For all screens of matching monitor number enable / disable touch

for( int i=0; i<dwMonParamCnt; i++ )

{

// where j is the screen number associated with the monitor number

for( int j=0; j<iScrCnt; j++ )

{

if( dwMonParam[i] == dwEnumMon[j] )

{

// Enables / Disables touch depending on the bFlag

// where j is the screen number

if( (iRet = EloSetTouchReportingState( bEnable , j )) == EloSuccess )

printf( "EloSetTouchReportingState Returned success\n" );

else

printf( "EloSetTouchReportingState Returned failed. Error \ Code=%d\n", iRet );

}

}

}

return EloSuccess;

}

// -----------------------------------------------------------------------------

// Processes command line options

void ProcessCmdLine( int argc, char** argv)

{

char *lpArg, *lpArg2 ;

char argstr[256]="";

LPTSTR lpCmdLine = argstr ;

strcpy( argstr,"" ) ;

for( int i=0; i<argc ; i++ )

{

strcat( argstr," " ) ;

strcat( argstr, argv[i] ) ;

}

lpArg = strstr(lpCmdLine,"-") ;

while (lpArg != NULL)

{

switch (lpArg[1])

{

case 'e':

// Enables / Disables touch depending on the Flag

// TRUE to enable , FALSE to disable

bEnable = TRUE;

break;

case 'd':

// Enables / Disables touch depending on the Flag

// TRUE to enable , FALSE to disable

bEnable = FALSE;

break;

case 'n':

// monitor number

if (lpArg[2] == ':')

lpArg++ ;

lpArg2 = strstr(lpArg+1,"-") ;

if (lpArg2 != NULL)

lpArg2-- ;

dwMonParam[dwMonParamCnt] = atoi(lpArg+2) ;

if (dwMonParam[dwMonParamCnt] > 0)

dwMonParamCnt++ ;

lpArg = strstr(lpArg+1,",") ;

while(lpArg != 0)

{

if(lpArg2 && (lpArg >= lpArg2)) break ;

dwMonParam[dwMonParamCnt] = atoi(lpArg+1) ;

if (dwMonParam[dwMonParamCnt] > 0)

dwMonParamCnt++ ;

lpArg = strstr(lpArg+1,",") ;

}

lpArg = lpArg2 ;

break ;

default:

printf( "Usage: EloEnableDisableSample -[e/d] \

-[n:<mon num>,[,<mon num>...]]\n\n \

-e \t\t\t\t: Enable touch\n \

-d \t\t\t\t: Disable Touch\n \

-n:<mon num>[,<mon num>...] \

\t: Monitors to enable or disable \n" ) ;

exit(0);

break ;

}

if (lpArg != 0)

lpArg = strstr(lpArg+1,"-") ;

}

}

// -------------------------------------------EOF-------------------------------