QueryProperty example for Delphi
Function TForm1.CheckCapability ( nValue: L_INT16 ): L_INT;
var
nRet: L_INT;
nIndex: L_INT;
ptwFixVal: pTW_FIX32;
twCap: TW_CAPABILITY;
pltQuery: pLTWAINPROPERTYQUERY;
begin
pltQuery:= Nil;
// Query capability possible values
nRet:= LEADTwain1.QueryProperty ( ICAP_XRESOLUTION, @pltQuery );
if ( nRet <> SUCCESS ) then
begin
Result:= nRet;
Exit;
end;
Case ( pltQuery.uType ) of
TWON_ONEVALUE:
begin
if ( pltQuery.pltwOneValue.ItemType = TWTY_FIX32 ) then
begin
ptwFixVal:= pTW_FIX32(pltQuery.pltwOneValue.Item);
if ( ptwFixVal.Whole = nValue ) then
begin
LEADTwain1.FreePropQueryStructure ( @pltQuery );
Result:= SUCCESS;
Exit;
end;
end;
end;
TWON_ENUMERATION:
begin
if ( pltQuery.pltwEnumeration.ItemType = TWTY_FIX32 ) then
begin
twCap.ConType:= TWON_ENUMERATION;
twCap.Cap:= ICAP_XRESOLUTION;
twCap.hContainer := GlobalHandle (pltQuery.pltwEnumeration);
for nIndex:= 0 to pltQuery.pltwEnumeration.NumItems-1 do
begin
LEADTwain1.GetNumericContainerFIX32Value ( @twCap, nIndex, @ptwFixVal );
if ( ptwFixVal.Whole = nValue ) then
begin
LEADTwain1.FreePropQueryStructure ( @pltQuery );
Result:= SUCCESS;
Exit;
end;
end;
end;
end;
end;
LEADTwain1.FreePropQueryStructure ( @pltQuery );
Result:= FAILURE;
end;