002
05.08.2003, 11:51 Uhr
~Gast
Gast
|
Okay dann will ich aml versuchen das Problem zu erklären. Ich habe von einem Hersteller von scannern eine Header-Datei bekommen in der beschrieben ist wie ich den Scanner aus meinen Programm über Twain Calibrieren kann ohne das deren Sofware aufgeht.
Der Code
C++: |
// //
#ifdef macintosh #include <TWAIN/TWAIN.h> #else #include "twain.h" #endif
// CAP_NEEDSCALIBRATION // Description: If TRUE, indicates the scanner calibration data is // not present. In this case, calibration data must be generated // via CAP_CALIBRATE before scanning will succeed. Note that // calibration is only required before the first scan after scanner // installation since the data persists on the host computer. // Type: TW_BOOL // Default Value: none // Allowed Values: TRUE or FALSE // MSG_GET container: TW_ONEVALUE // MSG_SET container: MSG_SET not allowed
const TW_UINT16 CAP_NEEDSCALIBRATION = CAP_CUSTOMBASE + 0x3e00;
// CAP_CALIBRATE // Description: When set to TRUE, the Source prompts the user to // insert the calibration target, verifies that the scanner has // something to scan (e.g. the calibration target) then calls a low- // level calibration routine. If calibration fails, an error message // is displayed. Set CAP_INDICATORS to FALSE to call the low-level // calibration routine without any user interface (i.e. user prompt // or error dialog). When the UI is spressed, CAP_FEEDERLOADED // should be used to verify that the calibration target is loaded // before calling CAP_CALIBRATE. // Result codes: // TWRC_SUCCESS calibration successful or user canceled // TWRC_FAILURE calibration failed // Type: TW_BOOL // Default Value: FALSE // Allowed Values: TRUE or FALSE // MSG_GET/SET container: TW_ONEVALUE
const TW_UINT16 CAP_CALIBRATE = CAP_CUSTOMBASE + 0x3e01;
// CAP_PREFEEDPAPER // Description: When set to TRUE, the Source feeds the paper by a // small amount. This capability is useful for "grabbing" (i.e. // prefeeding) the paper before scanning or calibrating. Poll with // CAP_FEEDERLOADED about every 500ms. When CAP_FEEDERLOADED changes // from FALSE to TRUE, set this capability to TRUE. // Type: TW_BOOL // Default Value: FALSE // Allowed Values: TRUE or FALSE // MSG_GET/SET container: TW_ONEVALUE
const TW_UINT16 CAP_PREFEEDPAPER = CAP_CUSTOMBASE + 0x3e02;
|
Nun habe ich eine zweite Classe mit der Ich uf Twain zugreife!!
C++: |
#ifndef __TWAINCPP_ #define __TWAINCPP_
#include "windows.h" #include "Twain.h"
#define TWCPP_ANYCOUNT (-1) #define TWCPP_CANCELTHIS (1) #define TWCPP_CANCELALL (2) #define TWCPP_DOTRANSFER (0)
class CTwain { public:
CTwain(HWND hWnd = NULL); virtual ~CTwain(); BOOL InitTwain(HWND hWnd); void ReleaseTwain();
/* This routine must be implemented by the dervied class After setting the required values in the m_AppId structure, the derived class should call the parent class implementation Refer Pg: 51 of the Twain Specification version 1.8 */ virtual void GetIdentity(); virtual BOOL SelectSource(); virtual BOOL OpenSource(TW_IDENTITY *pSource=NULL); virtual int ShouldTransfer(TW_IMAGEINFO& info) { return TWCPP_DOTRANSFER;}; BOOL ProcessMessage(MSG msg);
BOOL SelectDefaultSource(); BOOL IsValidDriver() const; BOOL SourceSelected() const {return m_bSourceSelected;} ; BOOL DSMOpen() const; BOOL DSOpen() const; BOOL SourceEnabled() const { return m_bSourceEnabled;}; BOOL ModalUI() const { return m_bModalUI; };
TW_INT16 GetRC() const { return m_returnCode; }; TW_STATUS GetStatus() const { return m_Status; };
BOOL SetImageCount(TW_INT16 nCount = 1); BOOL Acquire(int numImages=1);
protected: BOOL CallTwainProc(pTW_IDENTITY pOrigin,pTW_IDENTITY pDest, TW_UINT32 DG,TW_UINT16 DAT,TW_UINT16 MSG, TW_MEMREF pData); TW_UINT16 CallDSMEntry(pTW_IDENTITY pApp, pTW_IDENTITY pSrc, TW_UINT32 DG, TW_UINT16 DAT, TW_UINT16 MSG, TW_MEMREF pData);
void CloseDSM(); void CloseDS();
BOOL GetCapability(TW_CAPABILITY& twCap,TW_UINT16 cap,TW_UINT16 conType=TWON_DONTCARE16); BOOL GetCapability(TW_UINT16 cap,TW_UINT32& value); BOOL SetCapability(TW_UINT16 cap,TW_UINT16 value,BOOL sign=FALSE); BOOL SetCapability(TW_CAPABILITY& twCap); BOOL EnableSource(BOOL showUI = TRUE);
BOOL GetImageInfo(TW_IMAGEINFO& info);
virtual BOOL DisableSource(); virtual BOOL CanClose() { return TRUE; };
void TranslateMessage(TW_EVENT& twEvent); void TransferImage(); BOOL EndTransfer(); void CancelTransfer(); BOOL ShouldContinue(); BOOL GetImage(TW_IMAGEINFO& info);
virtual void SetImage(HANDLE hBitmap,TW_IMAGEINFO& info)=0; // virtual void CopyImage(HANDLE hBitmap,TW_IMAGEINFO& info);
protected: HINSTANCE m_hTwainDLL; DSMENTRYPROC m_pDSMProc;
TW_IDENTITY m_AppId; TW_IDENTITY m_Source; TW_STATUS m_Status; TW_INT16 m_returnCode; HWND m_hMessageWnd;
BOOL m_bSourceSelected; BOOL m_bDSMOpen; BOOL m_bDSOpen; BOOL m_bSourceEnabled; BOOL m_bModalUI;
int m_nImageCount; };
#endif
|
Von dieser Classe muß ich die Funktion
C++: |
BOOL SetCapability(TW_CAPABILITY& twCap);
|
oder
C++: |
BOOL SetCapability(TW_UINT16 cap,TW_UINT16 value,BOOL sign=FALSE);
|
benutzen. Jetzt hört es aber schon auf!! Was muß ich der funktion wie übergeben?? Hier noch die Funtion
C++: |
OOL CTwain::SetCapability(TW_CAPABILITY& cap) { if(DSOpen()) { return CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_CAPABILITY,MSG_SET,(TW_MEMREF)&cap); } return FALSE; }
|
Mein bisherriger Versuch sieht so aus:
C++: |
typedef struct {
TW_UINT16 Cap;
TW_UINT16 ConType;
TW_HANDLE hContainer;
} TW_CAPABILITY;
TW_CAPABILITY twc; twc.Cap=CAP_CALIBRATE; twc.ConType=TWON_ONEVALUE; //twc.hContainer=TWON_ONEVALUE;
SetCapability(twc);
|
|