VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 123456789[10] ]


[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 10:57:25 04/08/00 Sat
Author: Michel
Subject: Re: Scanning in CBuilder
In reply to: Cameron 's message, "Scanning in CBuilder" on 20:51:49 04/06/00 Thu


Hi Cameron,

I have created a simple BCB5 example and I think your problem is that you OnAcquire function is not a member function. The OnAquire function must be part of your main form (or another TObject descendant). For example, here is the class definition of the main form in my project:

class TMainForm : public TForm
{
__published: // IDE-managed Components
TImageScrollBox *ImageScrollBox;
TPanel *TopPanel;
TButton *ScanBtn;
TButton *SelectScannerBtn;
void __fastcall FormCreate(TObject *Sender);
void __fastcall FormDestroy(TObject *Sender);
void __fastcall ScanBtnClick(TObject *Sender);
void __fastcall SelectScannerBtnClick(TObject *Sender);
private: // User declarations
TScanner *FScanner;

void __fastcall ImageAcquired(
const unsigned DibHandle,
const Word XDpi,
const Word YDpi,
const int CallBackData);

public: // User declarations
__fastcall TMainForm(TComponent* Owner);
};

Then in the cpp file I have these two methods to handle the scanning:

void __fastcall TMainForm::ScanBtnClick(TObject *Sender)
{
FScanner->Acquire( ImageAcquired, 0 );
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::ImageAcquired(
const unsigned DibHandle,
const Word XDpi,
const Word YDpi,
const int CallBackData)
{
ImageScrollBox->Graphic->AssignFromDIBHandle(DibHandle);
ImageScrollBox->Redraw(True);
}

You'll may download the complete example project in,

<a rel=nofollow target=_blank href="http://www.intervalsoftware.com/files/scandemoCB5.zip">http://www.intervalsoftware.com/files/scandemoCB5.zip</a>

Best regards,

Michel

> I'm using a registered copy to create a program the
> activates a scanner and saves the output to the file.
> If I use the example Delphi code, everything is fine.
> But since I am more comforatble in C++, I've converted
> the program to C and have just one annoying problem.
> If I create an OnAcquire function to use in
> TScanner::Acquire, I get an error message
> E2031 Cannot cast from 'void (_fastcall *)(const
> unsigned int,const unsigned short,const unsigned
> short,const int)' to 'void (_fastcall * (_closure
> )(const unsigned int,const unsigned short,const
> unsigned short,const int))(const unsigned int,const
> unsigned short,const unsigned short,const int)'.
> How should the OnAcuire function be defined and
> call in C++ for the TScanner component to work.

[ Next Thread | Previous Thread | Next Message | Previous Message ]

[ Contact Forum Admin ]


Forum timezone: GMT-5
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.