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
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