FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ActiveX problem
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
ActiveX problem
Posted: Sun Jan 11, 2009 12:25 AM
Hi everyone;

I'm trying to use an ActiveX that works with a signing pad hardware. It contains a method to display a standard dialog to pickup a signature. When executed it looks like this:



After clicking [OK] the application aborts without showing any type of message. Clicking on [Clear] or [Cancel] work as expected. The error can't be trapped with TRY-CATCH-END. All other properties and methods seem to work just fine.

Here is part of the code:
//------------------------------------------------------------------------//

METHOD New( ) CLASS TePad
local lOk	:= .t.
local oErr

	
	DEFINE WINDOW ::oWnd FROM -300, -300 TO -300, -300	//hidden

TRY
	::oActiveX := TActiveX():New( ::oWnd, "esW25COM.esCapture.1" )
	::cDevice := ::oActiveX:GetProp( "ConnectedDevice" ) 

/*----------------------------------------------------------------------------
ConnectedDevice = 
{98C174D3-6D2A-4509-96DB-D5B34FA7A561}: Interlink ePadInk
{7FCD9512-8763-436E-8747-40972EE28EFD}: Interlink ePad
{C55C5D54-8A92-48AD-A32F-1FC58092A581}: Interlink ePadID 
------------------------------------------------------------------------------*/

CATCH oErr
	::end()
	Return Nil

END
	
RETURN Self 

//------------------------------------------------------------------------//
METHOD SetProp() CLASS TePad

	::oActiveX:SetProp( "SignDlgCaption", ::cCaption )
	::oActiveX:SetProp( "DisplayName", ::cDispName )
	::oActiveX:SetProp( "ShowSignerName", 1 )	//true
	::oActiveX:SetProp( "EnableAntiAliasing", 1 ) 

RETURN NIL

//------------------------------------------------------------------------//
METHOD PickUpSignature() CLASS TePad
local nRet 

TRY
	nRet := ::oActiveX:Do( "StartSign" , 0, 1 ) 
CATCH
	logfile( "trace.log", {"catched with errors"})
END

Logfile( "trace.log", { "Just testing", ::cDevice } )

Return nRet


To execute I simply do this:
Static Function Test()
Local oSign := TePad():New()

	if oSign <> nil
	
		oSign:cCaption := "Get Patient Signature Dialog"
		
		oSign:cDispName := ProperPatName( odbf ) + " Or Guardian"
		oSign:SetProp()
		
		oSign:PickUpSignature()
		oSign:End()
		
	endif


Any ideas how to debug this problem?


Reinaldo.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ActiveX problem
Posted: Sun Jan 11, 2009 07:09 AM

Reinaldo,

Please use oActiveX:bOnEvent to check what events you receive.

Please review FWH\samples\webexp.prg for an oActiveX:bOnEvent example of use.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: ActiveX problem
Posted: Sun Jan 11, 2009 08:11 AM

Hello Reinaldo,
there is a very good solution in FWPPC forum in pure FIVEWIN. This should work with FWH too.
Regards,
Otto

function Signature()

  local oMain, oSig, nHdc, ;
     nOldX := -1, ;
     nOldY := -1

  LOCAL DFILE := CURDIR() + &quot;\MYSIGN.BMP&quot;

  DEFINE WINDOW oMain TITLE &quot;Signature&quot;

  @40,5 SAY oSig PROMPT &quot;test&quot;+CRLF+&quot;test2&quot;+CRLF+dtoc(date())+&quot; - &quot; +time() SIZE 230,150 PIXEL BORDER

  @15, 5 BUTTON &quot;Clear&quot; SIZE 50,20 PIXEL ACTION oSig:refresh(.t.)
  @15,60 BUTTON &quot;Save&quot; SIZE 50,20 PIXEL ACTION ( oSig:saveToBmp( DFIle ), oSig:refresh(.t.), ReleaseDC( oSig:hWnd, oSig:hDC ), OMAIN:END() )

  nHdc := GetDC( oSig:hWnd )


  oSig:bLButtonUp := { |x,y,z| DoDraw( nHdc, y+1, x+1,@noldx,@noldy ), nOldX := -1, nOldY := -1 }
  oSig:bMMoved := { |x,y,z| DoDraw( nHdc, y, x ,@noldx,@noldy) }
  oSig:bLClicked := { |x,y,z| DoDraw( nHdc, y, x ,@noldx,@noldy) }

  ACTIVATE WINDOW oMain  MODAL

  return nil

//----------------------------------------------------------------------------//

STATIC Function DoDraw( hDc, x, y, noldx, noldy )

     If nOldX == -1 .And. nOldY == -1
        nOldX := x
        nOldY := y
        MoveTo( hDC, x, y )
     Else
        LineTo( hDc,x,y )
     EndIf

RETURN Nil

//----------------------------------------------------------------------------//

Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: ActiveX problem
Posted: Sun Jan 11, 2009 07:30 PM
Otto;

Thank you for your reply. I agree, that is an excellent example. However, not appropriate for a point of sale where you want to pick up a customer signature or a legal biding contract where you want the parties to sign some legal e-document.

The signature pad is used to pickup a customer signatures in stores and is widely used in the business world. You sign with a stylus which has a better feel than the mouse, and furthermore, the signing pad is on the other side of the desk easily available for the customer to sign. My intention is to store the signature in a blob field, so that it may be reproduced later.

Again, thank you for the reply; but I need to use a signing pad.

In case anyone is interested here is a link to some good signing pads that work with ocx controls:
http://www.interlinkelectronics.com/library/media/papers/pdf/epad-ink-datasheet-6-27.pdf


Reinaldo.
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: ActiveX problem
Posted: Sun Jan 11, 2009 07:51 PM

Hello Reinaldo,

you are right. I didn't thought on hardware.
Thank you for the link.
Regards,
Otto

Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: ActiveX problem
Posted: Sun Jan 11, 2009 08:04 PM
Antonio;

Did as per your suggestion. Here is my new code:
//------------------------------------------------------------------------//

METHOD New( oOwner, oProcess ) CLASS TePad
local lOk	:= .t.
local oErr
local cEvents	:= ""
	
	DEFINE WINDOW ::oWnd FROM -300, -300 TO -300, -300	//hidden

TRY
	::oActiveX := TActiveX():New( ::oWnd, "esW25COM.esCapture.1" )
	::cDevice := ::oActiveX:GetProp( "ConnectedDevice" ) 
	::oWnd:oClient := ::oActiveX
	::oActiveX:bOnEvent := { |e, a| cEvents += EventInfo( e, a ) }
CATCH oErr
	::end()
	Return Nil
END

	ACTIVATE WINDOW ::oWnd
	
RETURN Self 

//------------------------------------------------------------------------//
METHOD SetProp() CLASS TePad

	::oActiveX:SetProp( "SignDlgCaption", ::cCaption )
	::oActiveX:SetProp( "DisplayName", ::cDispName )
	::oActiveX:SetProp( "ShowSignerName", 1 )	//true
	::oActiveX:SetProp( "EnableAntiAliasing", 1 ) 

RETURN NIL

//------------------------------------------------------------------------//
METHOD PickUpSignature() CLASS TePad
local nRet 

TRY
	::oActiveX:Do( "StartSign" , 0, 1 ) 
CATCH
	logfile( "trace.log", {"catched with errors"})
END

Logfile( "trace.log", { "Just testing", ::cDevice } )

Return nRet

//------------------------------------------------------------------------//
static function EventInfo( e, a )
local cMsg 	:= "Event:" + cValToChar( e ) + CRLF
local n 

	cMsg += "Parms:"
	for n:=1 to Len ( a ) 
		cMsg += cValToChar( a[n] ) + CRLF
	next n
	
return cMsg + CRLF

And here is the code that calls that code:
Local oSign := TePad():New()

	if oSign <> nil
	
		oSign:cCaption := "Get Patient Signature Dialog"
		
		oSign:cDispName := ProperPatName( odbf ) + " Or Guardian"
		oSign:SetProp()
		
		oSign:PickUpSignature()
		oSign:End()
		
	endif


The standard signing dialog pops up and everything works as expected until I press the [ok] button. At that moment the application aborts and no messages are displayed. Nothing gets logged into trace.log either.

Any other ideas?


Reinaldo
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: ActiveX problem
Posted: Sun Jan 11, 2009 08:51 PM
Antonio;

I realized that I wasn't doing anything with bOnEvent, so I changed the line to this:
	::oActiveX:bOnEvent := { |e, a| logfile( "trace.log", {EventInfo( e, a ) } ) }


The following information gets logged as soon as the signing begins:
01/11/2009 15:48:34: Event:OnFirstTouch
Parms:

But after pressing [ok] nothing gets logged and the application aborts.



Reinaldo
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ActiveX problem
Posted: Mon Jan 12, 2009 12:07 AM

Reinaldo,

Are you sure that you have to use it as an ActiveX ?

Maybe you should create it using CreateObject() and manage it as an OLE object, not as an ActiveX.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: ActiveX problem
Posted: Mon Jan 12, 2009 08:28 PM
Tried it. Same result. I only wish I could stop execution to see what's happening after the [ok] button on that dialog is doing. Here is my new code:
//------------------------------------------------------------------------//
METHOD New() CLASS TePad

TRY
	::oActiveX := GETACTIVEOBJECT( "esW25COM.esCapture.1" )
CATCH
	TRY
		::oActiveX := CREATEOBJECT( "esW25COM.esCapture.1" )
	CATCH
		Alert( "ERROR! SigningPad not avialable. [" + Ole2TxtError()+ "]" )
		::end()
		Return Nil
	END
END

RETURN Self 

//------------------------------------------------------------------------//
METHOD SetProp() CLASS TePad

	::oActiveX:SignDlgCaption := ::cCaption
	
RETURN NIL

//------------------------------------------------------------------------//
METHOD PickUpSignature() CLASS TePad
local nRet 

TRY
	::oActiveX:ClearSign()
	::oActiveX:StartSign( 0, 1 )
CATCH
	logfile( "trace.log", {"catched with errors"})
END

Logfile( "trace.log", { "Just testing", ::cDevice } )

Return nRet


The dialog hast three buttons. [Clear], [Cancel], [Ok]. Clicking on any of these and it all work as expected, except when clicking on [Ok] after signing. The app simply aborts.



Reinaldo.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ActiveX problem
Posted: Mon Jan 12, 2009 09:10 PM

Reinaldo,

Is ::oActiveX:StartSign( 0, 1 ) the method to invoke the signature dialogbox ?

What 0 and 1 mean ?
Do you have any example of use in VB, C, etc. or docs for it ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: ActiveX problem
Posted: Mon Jan 12, 2009 10:05 PM
Antonio;

Good idea. Here is a link to the documentation and the actual ocx and dll needed for testing:

http://ssfl.dynalias.com/temp

Download the .pdf and the .ocx and the .dll for your own tests. [I think] The only thing you won't be able to do without the pad is the actual signing, therefore you won't be able to test the ok button.

The ocx is usable for different models. The model I'm testing is the ePad id. That first parameter does nothing with the ePad Id. On a ePad Ink, it would control the number of buttons to display on the pad. Here is a link to their devices:

http://www.interlinkelectronics.com/esign/products/epad/index.html

Thank you for your help.


Reinaldo.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ActiveX problem
Posted: Tue Jan 13, 2009 12:14 AM

Reinaldo,

What we need is that you locate some VB or C example code for it and post it here to review it, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: ActiveX problem
Posted: Tue Jan 13, 2009 12:20 AM
Ok. Here is the whole vb project and also the .exe build of the sample code:
http://ssfl.dynalias.com/temp/epad_vb_sample

Reinaldo.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ActiveX problem
Posted: Tue Jan 13, 2009 12:30 AM
Reinaldo,

Is your PRG code similar to this one ?
Private Sub CmdStartSign_Click()
    SignData = vbNullString
    'set the sign dialog caption
    IntegriSign1.SignDlgCaption = "IntegriSign Signature Capture"
    'set the data to be associated with the signature
    IntegriSign1.HashData = txtHashData.Text
    'set whether cross mark needs to be displayed if content is modified
    If chkAppOptions(5).Value = 0 Then
        IntegriSign1.Cross = Cross_OFF
    Else
        IntegriSign1.Cross = Cross_ON
    End If
    'initiate the act of signing
    IntegriSign1.StartSign cmbBut.ListIndex, chkAppOptions(6).Value
    If chkAppOptions(6).Value = 1 Then
        lblft.Caption = vbNullString
    End If
End Sub
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: ActiveX problem
Posted: Tue Jan 13, 2009 12:50 AM
Well... I'm skipping some of the optional statements. According to the documentation you don't have to set hash data if you don't need signature validation. I'm not setting the .cross property either, since I'm not doing the hashing anyway. So actually, my code is much simpler. I first create the Ole instance object, set the dialog caption, and proceed to StartSign().

So basically my code is:

	::oActiveX := CREATEOBJECT( "esW25COM.esCapture.1" )
	::oActiveX:SignDlgCaption := ::cCaption
	::oActiveX:StartSign( 0, 1 )


For some reason it all works well in their sample apps. But pressing [ok] after taking the signature breaks my app. I'll continue to investigate.

Thank you,


Reinaldo