QueryProperty example for C++ Builder
int TForm1::CheckCapability ( L_INT16 nValue )
{
L_INT nRet;
L_INT nIndex;
pTW_FIX32 ptwFixVal;
TW_CAPABILITY twCap;
pLTWAINPROPERTYQUERY pltQuery= NULL;
// Query capability possible values
nRet= LEADTwain1->QueryProperty ( ICAP_XRESOLUTION, &pltQuery );
if ( nRet != SUCCESS )
{
return nRet;
}
switch (pltQuery->uType)
{
case TWON_ONEVALUE:
{
if ( pltQuery->pltwOneValue->ItemType == TWTY_FIX32 )
{
ptwFixVal= (pTW_FIX32)(pltQuery->pltwOneValue->Item);
if ( ptwFixVal->Whole == nValue )
{
LEADTwain1->FreePropQueryStructure ( &pltQuery );
return SUCCESS;
}
}
}
break;
case TWON_ENUMERATION:
{
if ( pltQuery->pltwEnumeration->ItemType == TWTY_FIX32 )
{
twCap.ConType= TWON_ENUMERATION;
twCap.Cap= ICAP_XRESOLUTION;
twCap.hContainer= (TW_HANDLE)GlobalHandle (pltQuery->pltwEnumeration);
for (nIndex= 0; nIndex < (L_INT)pltQuery->pltwEnumeration->NumItems; nIndex ++ )
{
LEADTwain1->GetNumericContainerFIX32Value ( &twCap, nIndex, ptwFixVal );
if ( ptwFixVal->Whole == nValue )
{
LEADTwain1->FreePropQueryStructure ( &pltQuery );
return SUCCESS;
}
}
}
}
break;
}
LEADTwain1->FreePropQueryStructure ( &pltQuery );
return FAILURE;
}