Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ReportListener Run-Time field alignment
Message
 
To
06/10/2004 16:42:59
Walter Nicholls
Cornerstone Software Ltd
Auckland, New Zealand
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Beta
Miscellaneous
Thread ID:
00949327
Message ID:
00949746
Views:
23
Walter,

I appreciate your reply, it pointed me in the right direction. I added some code to the Render() method in my custom Report Listener class to manually paint the field using GDI+ if the alignment needed to be changed on-the-fly.
My custom class includes pieces gleaned from your excellent GDI+ articles in FoxTalk 2.0 and Cathy Poutney's MSDN articles on the VFP 9.0 Report Writer.
Part of the GDI specific section of code is below:

Thanks,
Paul
-----------
Render(tnFRXRecNo, tnX, tnY, tnWidth, tnHeight, tnObjectContinuationType, tcContentsToBeRendered, tGDIPlusImage)

*Is this a 'Text' object?
llTextType = INLIST(Frx.ObjType,  FRX_OBJTYP_LABEL, FRX_OBJTYP_FIELD)

If llTextType
  *Text is stored as UniCode and must be converted for our use.
  lcContents = STRCONV(TRANSFORM(tcContentsToBeRendered),STRCONV_UNICODE_UTF8)

   Local oBounds As GpRectangle Of _gdiplus.vcx &&\VFP\FFC\_gdiplus.vcx
   Local oGr As GpGraphics Of _gdiplus.vcx
   Local oLineColor As GpColor Of _gdiplus.vcx
   Local Open As GpPen Of _gdiplus.vcx
   Local oBrush As GpSolidBrush Of _gdiplus.vcx

   *Create a rectangle object storing the bounding box of our drawing
   oBounds = Newobject('GpRectangle','_gdiplus.vcx','', lnX, lnY, tnWidth, tnHeight)
   *Associate graphics object with the reportlistener graphics handle.
   oGr = Newobject('GpGraphics','_gdiplus.vcx')
   oGr.SetHandle(This.oListener.GDIPlusGraphics)

   oLineColor = Newobject('GpColor','_gdiplus.vcx','', 0,0,0) &&black
   Open = Newobject('GpPen', '_gdiplus.vcx','', oLineColor)   &&1-pixel
   oBrush = Newobject('GpSolidBrush', '_gdiplus.vcx','')
   oBrush.Create()  && don't specify color yet

   *To draw text create a GpFont object.  (Arial, Bold, 12 Point)
   oFont = Newobject('GpFont','_gdiplus.vcx')
   oFont.Create("Arial", 10, GDIPLUS_FontStyle_Regular, GDIPLUS_Unit_Point) 

   oStringFormat = Newobject('GpStringFormat','_gdiplus.vcx')
   oStringFormat.Create()

   *--Set the Alignment!
   oStringFormat.Alignment = lnAlign
   oBrush.BrushColor = 0xA8000000  &&66% black
   oGr.DrawStringA(lcContents, oFont, oBounds, oStringFormat, oBrush)
Endif
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform