DTwainSource::SetSingleCapValue |
Top Previous Next |
Syntax
bool DTwainSource::SetSingleCapValue( LONG Cap, LONG Value );
bool DTwainSource::SetSingleCapValue( LONG Cap, const std::string& Value );
bool DTwainSource::SetSingleCapValue( LONG Cap, double Value );
bool DTwainSource::SetSingleCapValue( LONG Cap, const DTwainFrame& Value );
Parameters Cap Capability values to get.
Value Value to use to set for the capability
Return Value true if successful, false if unsuccessful.
Comments The DTwainSource::SetSingleCapValue function sets a capability of the source to a single value. This function is a specialized version of DTwainSource::SetCapValues, the difference being that DTwainSource::SetCapValues can set a capbility with multiple values, while DTwainSource::SetSingleCapValue sets only one value..
There are four forms of CDTwainSource::SetSingleCapValue. All the forms are both equivalent in terms of every parameter except the Value parameter. The lCap parameter is one of the capability constants (for example, DTWAIN_CV_ICAPBITDEPTH or DTWAIN_CV_CAPAUTHOR. See the main help manual for a complete list of these constants).
The Value parameter will be either a long value, string value, double (real) value, or DTwainFrame value. The type of value to use depends on the lCap parameter. If the wrong value type is used for the lCap value type, DTwainSource::SetSingleCapValue returns false. In general, the vector types are determined by the following:
If the capability supports an integer type (long, int, boolean, etc.), the type to use is LONG or long. If the capability supports a floating point type, the type to use is double. If the capability supports a string type, the type to use is std::string, If the capability supports a TW_FRAME type, the vector to use is DTwainFrame.
To set the data type for a specific capability, you can get the data type defined in the DTWAIN Capability constants in the main help manual, or call DTwainSource::GetCapDataType( ) to determine the type. Here is a table of the return value from DTwainSource::GetCapDataType, and the correspoding vector type to use:
A return value of false from DTwainSource::SetSingleCapValue could mean one of the following:
As an example, to set the capability values for DTWAIN_CV_ICAPXRESOLUTION, the data types that will be stored are DTWAIN_FLOATs. In this case, the call to DTwainSource::SetSingleCapValues must use a double as the Value parameter (assume the Source supports setting the x-resolution value to 300).
#include <cdtwain.h> using namespace DTWAIN;
int main( ) { DTwainInterface TI; // start DTWAIN and a Twain session DTwainSource Source = DTwainSource::Select( );
// set the resolution value to 300 DPI Source.SetSingleCapValue( DTWAIN_CV_ICAPXRESOLUTION, 300.0 ); }
|