Hi Merlin.
I hope, I can help with following (Simplified source)
To prevent problems caused by the scanner being switched off or (mostly) in energy saving mode, we use a 'ScannerCheck' before each scan:
Function TDataModule1.ScannerCheck(Source:String):Boolean;
// 'Source' is stored in a database or ini or registry...
var aImageEnIO:TImageEnIO;
NewSource:String;
ADevice : TIEAcquireSource;
begin
result := FALSE;
NewSource := Source;
ADevice := StrToAcquireSource(Source);
aImageEnIO := TImageEnIO.Create(self);
try
result := aImageEnIO.SetAcquireSource(ADevice.Api, ADevice.Location);
if result then result := aImageEnIO.TwainParams.GetFromScanner;
if (Source = '') or (not result) then
begin
ShowMessage('Scanner ist nicht bereit'+#13#10+
'Ist der Scanner korrekt angeschlossen und eingeschaltet?');
// ... dann Scanner auswählen
result := aImageEnIO.SelectAcquireSource([ieaTwain, ieaWIA]);
if result then
NewSource := AcquireSourceToStr(aImageEnIO.SelectedAcquireSource);
if NewSource <> Source then
begin
// wollen Sie wirklich diesen Scanner auswählen:
// NewAcquisitionSource
// wenn ja, dann
ADevice := StrToAcquireSource(NewSource);
if MessageDlg('Wollen Sie diesen Scanner auswählen:?'+
+#13#10+AcquireSourceToStr(ADevice), mtConfirmation,
[mbYes, mbNo], 0, mbYes) = mrYes then
begin
Source := NewSource;
// store 'Source' to a database or ini or registry...
result := aImageEnIO.TwainParams.GetFromScanner;
end else result := FALSE;
end;
end;
finally
aImageEnIO.Free;
end;
end;
procedure TMainForm.TestScanButtonClick(Sender: TObject);
var oldCursor:TCursor;
begin
if not DataModule1.ScannerCheck then exit;
oldCursor := Screen.Cursor;
Screen.Cursor := crHourGlass;
try
result := MainForm.ImageEnIO1.Acquire;
finally
Screen.Cursor := oldCursor;
SelectedBitmap.Assign(ImageEnIO1.IEBitmap);
// or ImageEnView.IEBitmap.Assign(ImageEnIO1.IEBitmap);
end;
end;
Fritz