VpeGetObjectID

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

VpeGetObjectID

Postby Bengt » Thu Apr 10, 2014 3:27 pm

I use the VPE classes for Visual DataFlex from StarZen for printing documents and sending E-mail.

According to the VPE manual, VpeGetObjectID shall return the object ID of the clicked object.

Two different documents are previewed and shown at the same time on the screen. The user can click on the E-mail icon and different files shall be attached to the mail depending on which document is clicked.

When previewing each of these documents I set object id’s with Send DoVpeSetObjectID idNr but when I try to retrieve the calling objects id in Procedure OnVpeBeforeMail with Get DoVpeGetObjectID to iObjectID, I always get -1163005939. What is wrong?

Bengt
Bengt
 
Posts: 89
Joined: Fri Jan 27, 2006 5:29 pm

Re: VpeGetObjectID

Postby IDEAL Software Support » Fri Apr 11, 2014 7:55 am

This is explained in the help file / manual.

VpeGetObjectID(): "This property is only accessible while your application is processing the event VPE_OBJECTCLICKED. Calling this function while not processing the event will return invalid - and therefore useless - data."

You need to process the event VPE_OBJECTCLICKED. In the event handler read the value of the property ObjectID and store it in a variable of your application (say it is named LastClickedObjectID).

When processing the event VPE_BEFORE_MAIL, you can check the value of your variable LastClickedObjectID.
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm

Re: VpeGetObjectID

Postby Bengt » Wed Apr 16, 2014 8:57 pm

I am able to set an objet id on a text string and when clicking on the text, VpeGetObjectID is executed as described in the VPE manual under VpeSetObjectID. But what I need is to set an objectID that is retrieved when clicking on the preview mail icon. How can that be done?

I tried to do it by Send DoVpeSetObjectID 20 before previewing the document but that didn't work. VpeBeforeMail is executed but
VpeGetObjectID is not when clicking the mail icon.

Regards
Bengt


Code: Select all
//My test code
Procedure OnVpeObjectClicked Integer wParam Integer lParam 
  Integer iObjid
  Get DoVpeGetObjectID to iObjID
  Send Info_Box ("Object " + String(iObjId) + " clicked")
End_Procedure

Procedure OnVpeBeforeMail
    String sText sDir sNr sLongPath sCRLF sMailAdress
    Boolean bFileExist
    Send DoVpeClearMailReceivers
    Move 'myadress@telia.com' to sMailAdress
    If (sMailAdress <> '') Begin
        If (FIR.SMTP='J') Send DoVpeAddMailReceiver ("SMTP:" + ToANSI(sMailAdress)) VMAIL_TO
        Else Send DoVpeAddMailReceiver (ToANSI(sMailAdress)) VMAIL_TO
    End
End_Procedure

Procedure RunDocument Integer bPreview
    Send OpenDoc
    Send DoVpeSetPageFormat VPAPER_A4
    Send DoVpeSetObjectID 15
    Send DoVpePrint 1 1 "Monthly Report"  //When clicking on the text, OnVpeObjectClicked is executed

    Send DoVpeSetObjectID 20
    Send PreviewDoc VPE_SHOW_NORMAL  //When clicking on the preview or the preview mail icon,  OnVpeObjectClicked is NOT executed

    Send DoVpeRefreshDoc
End_Procedure
Bengt
 
Posts: 89
Joined: Fri Jan 27, 2006 5:29 pm

Re: VpeGetObjectID

Postby IDEAL Software Support » Thu Apr 17, 2014 6:58 am

Please read my previous answer carefully. It explains what is needed to do.
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm

Re: VpeGetObjectID

Postby Bengt » Thu Apr 17, 2014 8:17 am

It is not a question of reading, but of understanding. I don't understand what you mean.

When clicking the mail icon, VPE_OBJECTCLICKED is not processed. How can then the objectID be read?

I can call VpeObjectClicked from VpeBeforeMail, but then invalid data is returned.
Bengt
 
Posts: 89
Joined: Fri Jan 27, 2006 5:29 pm

Re: VpeGetObjectID

Postby IDEAL Software Support » Thu Apr 17, 2014 9:01 am

Maybe I misunderstood your initial question.

Do you want to know what graphical object (for a specific document) in a preview is clicked, or for what document the e-mail button in the toolbar is clicked?

In the latter case neither VpeGetObjectID nor the event VPE_OBJECTCLICKED are what you are looking for. The event VPE_OBJECTCLICKED is for objects like text, images, barcodes, etc. which are clicked by the user in the preview. This has nothing to do with the toolbar. For the toolbar, other events are sent.

From you code, I assume you are using the VPE ActiveX. For the ActiveX you are working with different instances of the VpeControl class for different documents. So, if you are showing two different documents at the same time, you have two instances of the VpeControl. Say, they are named Doc1 and Doc2.

I don't know the Visual Dataflex programming language. Other languages either provide to event handlers a parameter with the instance of the object which sent the event I.e. the event handler has a signature like OnVpeBeforeMail(VpeControl sender), by testing if sender = Doc1 ... else if sender = Doc2 you can determine which instance sent the event.

Or there are also languages, which bind event handlers directly to an object instance, i.e. one event handler is named Doc1_OnVpeBeforeMail() and the other Doc2_OnVpeBeforeMail(), which are two separate event handler functions.

To find out how this is handled by Visual Dataflex , please contact Starzen (which provides support for VDF with VPE), or Visual Dataflex technical support or a related forum.
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm

Re: VpeGetObjectID

Postby IDEAL Software Support » Thu Apr 17, 2014 9:14 am

PS: If you are using the VPE DLL, it is nearly the same.

Each call to OpenDoc() returns a handle, which is nothing else, but an instance of a VPE document.

i.e.
VpeHandle hDoc1 = VpeOpenDoc()
VpeHandle hDoc2 = VpeOpenDoc()

creates two different documents at the same time.

When the VPE DLL sends an event, it provides in the parameter lParam always the document handle of the document which did send the event. Therefore you can distinguish in your event-handler, what document instance did send the event, by comparing the handles, which are unique.

It depends on your Visual Dataflex VPE API bindings, where and how you receive this parameter. If you are using the VPE API bindings created by Starzen, please contact Starzen. Otherwise contact the person or company, which did create the VPE API bindings you are using.
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm

Re: VpeGetObjectID

Postby Bengt » Thu Apr 17, 2014 1:48 pm

I use the Visual DataFlex VPE API binding from StarZen. As far as I understand it is the VPE DLL I use. At least I need to distribute the VPE DLL files to get my application working.

It seems to me that the handle is excluded from the mail functions in the implementation from StarZen. All mail functions are carried out with the last opened document. It works when only one document is previewed, but not if two is shown on the same time and you click on the mail button of the first document.

VisualDatafelx code from StarZen

Code: Select all
Procedure OnVpeBeforeMail
End_Procedure

Procedure OnVpeBeforeMail
    If (phoCurrentDocument(Self)) Send OnVpeBeforeMail TO (phoCurrentDocument(Self))
End_Procedure

Send DoVpeAddMailReceiver (ToANSI(sMailAdress)) VMAIL_TO  //My code but it works when one document is open.


Delphi code from vpedemo

Code: Select all
procedure TForm1.BeforeMail(Sender: TVPEngine; var Cancel:Boolean);
begin
  ShowMessage('Caught event from VPE: --- BEFORE Mail ---' + #10 + #10 +
              'Now you could invisibly add recipients, attachments, text, etc. by code.');
end;


Fróm VPE manual

Code: Select all
VpeAddMailReceiver(hDoc, "max@alpha.com", VMAIL_CC)


The Sender and hDoc are missing in the Visual DataFlex code.

I suppose I must contact Mike on StarZen, but it is always very difficult to get into contact with him.

Regards,
Bengt
Bengt
 
Posts: 89
Joined: Fri Jan 27, 2006 5:29 pm


Return to VPE Open Forum

Who is online

Users browsing this forum: No registered users and 13 guests

cron