TwainPRO 9 for ActiveX - User Guide > How To > Negotiate Capabilities > Check Capabilities |
Data Sources have different capabilities (e.g. levels of resolution, support of color or black and white images, automatic document feeder available, etc.). Applications can check the capabilities available for the selected Data Source, and can also set those capabilities to its desired settings.
Capabilities can be checked once a TWAIN Session has been opened (OpenSession), and before or after a scanning session has been initiated (StartSession). |
First specify the capability to be read, by setting the Capability property.
To determine whether the selected Capability is supported by the Data Source, read the CapSupported property.
If the capability is supported by the Data Source, read the CapType property to determine the type of container used by the Data Source to pass values back to TwainPRO™.
The relevant properties to access for a capability are determined by the container used (CapType). TWAIN defines four types of containers to negotiate values between the application (TwainPRO) and the Source:
TWON_ONEVALUE: The current value is returned
Relevant Properties To Check: CapValue
TWON_ENUM: A list of legal values along with the current and default values are returned
Relevant Properties To Check: CapValue, CapDefault, CapNumItems, CapItem
TWON_RANGE: A range of legal values along with the current and default values are returned
Relevant Properties To Check: CapValue, CapDefault, CapMin, CapMax, CapStep
TWON_ARRAY: A list of values is returned
Relevant Properties To Check: CapNumItems, CapItem
VB Example |
Copy Code
|
---|---|
' This code demonstrates how to read a value ' Check for support and stop if none If (TwainPRO.CapSupported = False) Then LblDefault.Caption = "Not supported" LblDefault.Visible = True Exit Sub End If ' What data type is the Cap? We have to check the ' data type to know which properties are valid Select Case TwainPRO.CapType ' Type ONEVALUE only returns a single value Case TWON_ONEVALUE EdtCurrent.Text = TwainPRO.CapValue EdtCurrent.Visible = True ' Type ENUM returns a list of legal values as ' well as current and default values. A list ' of constants is returned and the CapDesc ' property can be used to find out what the ' constants mean Case TWON_ENUM EdtCurrent.Text = TwainPRO.CapValue EdtCurrent.Visible = True LblDefault.Caption = "Default = " & TwainPRO.CapDefault LblDefault.Visible = True List1.AddItem "Legal Values:" For Index = 0 To TwainPRO.CapNumItems - 1 List1.AddItem TwainPRO.CapItem(Index) & " - " & TwainPRO.CapDesc(TwainPRO.CapItem(Index)) Next List1.Visible = True ' Type ARRAY returns a list of values, but no ' current or default values. Case TWON_ARRAY List1.AddItem "Legal Values:" For Index = 0 To TwainPRO.CapNumItems - 1 List1.AddItem TwainPRO.CapItem(Index) Next ' Returns a range of values as well as current and ' default values Case TWON_RANGE EdtCurrent.Text = TwainPRO.CapValue EdtCurrent.Visible = True LblDefault.Caption = "Default = " & TwainPRO.CapDefault LblDefault.Visible = True LblMin.Caption = "MinValue = " & TwainPRO.CapMin LblMin.Visible = True LblMax.Caption = "MaxValue = " & TwainPRO.CapMax LblMax.Visible = True End Select |