Search code examples
powerbuilderscanningtwain

How to use TWAIN in a Powerbuilder application


We have a powerbuilder application and we want use a scanner through this application with the use of the TWAIN drivers. Does anyone have previous experience or code samples about how this can be developed?


Solution

  • It's hard (and may be impossible) to integrate TWAIN into PowerBuilder using plain PowerScript (without regard for possible ActiveX control).

    Working solution (for me) was creation of Dll (C++) based on TWAIN Sample code. In brief

    • PowerBuilder app creates response window (modal dialog)
    • call Dll function to override window proc: SetWindowLong(handle(..), GWL_WNDPROC, MyFunction)
    • and initiate TWAIN transfer.

    Sample application in C++ is working. But, of course, some changes required to adopt it for PowerBuilder.