Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP 9.0 ReportListener

Status
Not open for further replies.

randallJ

IS-IT--Management
Aug 15, 2000
90
GB
I need to center images of varying sizes on a page and have been advised my MS that the only way to do this is by using the reportlistener in VFP 9.0. However I am really struggling to get to grips with this. Does anyone out there have any experience with subclassing the reportlistener and what is the render event? How do I make the two talk to each other. Below is what MS sent me to get me started:

We would subclass a ReportListener and listen to the Render event. When the render event fires for this particular image control, get the filename of the image which should be passed in the cContentsToBeRendered parameter. Then you can use the gpImage class in the _GDIPLUS FFC class to open the image and retrieve its height and width. Then using some math figure out if it needs to be centered (compare these image size to the position Render passes in). Finally, do a DODEFAULT with new coordinates to center the image. Here is some pseudo code to summarize the process:



subclassed ReportListener

proc Render(...,L, T, W, H, Contents,...)

if (IsImageControl AND ShouldBeCentered)

oImage.OpenFile(Contents) &&Use the GDI+ (gpImage class) to open

Get Height/Width from oImage

Use Image Height/Width to see how it would fit in L,R,W,H and figure out new values for L/R/W/H

DoDefault(..., NewL, T, NewW, H, Contents, ...) &&Update the coordinates so it is horizontally centered (you can do vertical centering too)

NODEFAULT &&Suppress the original size

endif

endproc



 

Is this to center an image on a report?
This reply from Microsoft? I have a feeling they are refering to GDI+ API flat calls rather than using the _GDIPLUS library. If so it is a little mixed.



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Yes it is to center an image on a report. Do you understand what they want me to do?
 

Yes I understand the concept. But if you called Microsoft for support, I wonder why they gave you pseudo-code rather then real code.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
I tried to use one of the free support tickets you get when you buy the software, but they said because I had to tap into the report listener this was not covered and the most they could do was point me in the right direction. If I wanted them to write the code for me I would have to pay them their going daily rate and it would probably take 2 weeks and they could not guarantee the outcome!
 
Here an example. This will work if you have VFP9 installed, and this example uses _GDIPLUS.vcx and not API calls. The first line instaciates the reportlistener. The second line creates a new image (this is the way GDI works, you never work with the actual image, but a copy of it). The third line get your image. The last lines tells you the top,left, height and witdth of the image.
Code:
oListener = CREATEOBJECT('reportlistener') 
oImage= newobject('GpBitmap',HOME(1)+'ffc/_gdiplus.vcx')
 oImage.CreateFromFile(GETPICT())
? oImage.left
? oImage.top
? oImage.width 
? oImage.Height



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Thank you very much for your sample, however although I can get the co-ordinates of my image how do I reposition it so that it is centered. Currently an image control is displayed in the top left hand corner of the page.
 
If you do a little digging in the report listener(_reportlistener.vcx), you will find this procedure (Render) that will do what you need (ie. specifying the top and left properties)
Code:
LPARAMETERS nFRXRecno, nLeft, nTop, nWidth, nHeight, nObjectContinuationType, cContentsToBeRendered, GDIPlusImage
IF NOT ISNULL(THIS.Successor)
   THIS.SetSuccessorDynamicProperties()
   THIS.Successor.Render(nFRXRecno, nLeft, nTop, nWidth, nHeight, nObjectContinuationType, cContentsToBeRendered, GDIPlusImage)
ENDIF

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Mike

You will have to excuse me, this is very new territory for me. I have have an example of the render procedure which I found in the help text.
"PROCEDURE RENDER(nFRXRecNo,;
nLeft,nTop,nWidth,nHeight,;
nObjectContinuationType, ;
cContentsToBeRendered, GDIPlusImage)

LOCAL llCopyImage, lcFile

IF THIS.CopyImageFilesToExternalFileLocation
THIS.SetFRXDataSession()
GO nFRXRecNo IN FRX
IF FRX.ObjType = FRX_OBJTYP_PICTURE AND ;
FRX.Offset # FRX_PICTURE_SOURCE_GENERAL AND ;
FILE(cContentsToBeRendered)
llCopyImage = .T.
ENDIF
THIS.SetCurrentDataSession()
ENDIF

IF llCopyImage
lcFile = FORCEPATH(cContentsToBeRendered, ;
FULLPATH(THIS.ExternalFileLocation, ;
ADDBS(JUSTPATH(THIS.TargetFileName))))
IF NOT FILE(lcFile)
COPY FILE (cContentsToBeRendered) TO (lcFile)
ENDIF
ENDIF

DODEFAULT(nFRXRecNo,;
nLeft,nTop,nWidth,nHeight,;
nObjectContinuationType, ;
cContentsToBeRendered, GDIPlusImage)
ENDPROC
"

But I don't know what to do with it, where to start, or how to get both my subclassed listener object and the render procedure to talk to my report or my data. I am really really lost. There doesn't seem to be that much help out there with regards to books or courses for reporting in 9.0 even though so much has changed. Any ideas greatly appreciated.
 
Thanks Jim

These white papers seem very informative, hopefully they'll help me to piece everything together and create a greater understanding of how it all works!
 
Here are a couple more links.


There doesn't seem to be that much help out there with regards to books or courses for reporting in 9.0 even though so much has changed.

The reportlistener is fairly new, so books and articles are scarce at the moment. But they are starting to come.
I understand that it is frustrating when you trying to do something and the net does not provide you with the answer. But I can tell you this, having worked the the report listener I can assure you that what you want to do is quite feasible, I just haven't had the demand for this, so I have not worked out a solution for it.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
In addition to the references you've already been pointed to, Doug Hennig has written about report listeners both in FoxTalk and in our book, What's New in Nine.

Tamar
 
Thank you all for pointing me in the right direction. Looks like I need to start reading!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top