使用TDELPHITWAIN时,在控制的界面按取消按钮后,不能重新打开控制界面
原码:
unit SimpleExampleForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, DelphiTwain;
type
TForm1 = class(TForm)
Title: TPanel;
ImageHolder: TImage;
GoAcquire: TButton;
Twain: TDelphiTwain;
procedure GoAcquireClick(Sender: TObject);
procedure TwainTwainAcquire(Sender: TObject; const Index: Integer;
Image: TBitmap; var Cancel: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{Acquire into image}
procedure TForm1.GoAcquireClick(Sender: TObject);
var
SelectedSource: Integer;
begin
{It is always recommended to load library dynamically, never forcing}
{final user to have twain installed}
if Twain.LoadLibrary then
begin
{Load source manager}
Twain.SourceManagerLoaded := TRUE;
{Allow user to select source}
SelectedSource := Twain.SelectSource;
if SelectedSource <> -1 then
begin
{Load source, select transference method and enable (display interface)}
Twain.Source[SelectedSource].Loaded := TRUE;
Twain.Source[SelectedSource].TransferMode := ttmMemory;
Twain.Source[SelectedSource].Enabled := TRUE;
end {if SelectedSource <> -1}
end
else
showmessage('Twain is not installed.');
end;
{Image acquired}
procedure TForm1.TwainTwainAcquire(Sender: TObject; const Index: Integer;
Image: TBitmap; var Cancel: Boolean);
begin
ImageHolder.Picture.Assign(Image);
Cancel := TRUE; {Only want one image}
end;
end.
出现步骤:
1.点击扫描按钮
2.选择扫描的驱动,点击确定,然后出现控制扫描的窗口
3.在控制扫描的窗口按“取消”按钮
4.再次点击扫描按钮,出现选择驱动窗口,选择驱动后,控制扫描的窗口没有出现