determining the pixel space that a canvas.TextOut object use

TeeChart for ActiveX, COM and ASP
Post Reply
scott
Newbie
Newbie
Posts: 10
Joined: Mon Dec 22, 2003 5:00 am
Location: Phoenix, AZ

determining the pixel space that a canvas.TextOut object use

Post by scott » Fri Aug 06, 2004 8:35 pm

I am using the TChart.Canvas.Textout object to output current date/time. Currently I use 2 lines (top line for the date, bottom line for the time). I want to be able to display the current date/time on a single line such that the is a small space between the date and time. The date that is displayed (the format) is based on the current regional settings for the PC. Users are also able to change the font size of the displayed date/time. The following shows the current code :

Code: Select all

Const cDateXOffset = 20	' Horiz. distance between end of X axis and where to display date text

nLineHeight = g_nLegendFontSize * TChart1.Axis.Left.Labels.Font.PixelsPerInch / 72 + 1	
nDateXPos = TChart1.Axis.Right.Position + TChart1.Aspect.Width3D - (8*cDateXOffset - 10)
nDateYPos = TChart1.Canvas.Top - 60
nDateYPos = nDateYPos + nLineHeight*4

.Font.Color = vbBlack
sDateTime = FormatDateTime(g_dtMaxTime, vbShortDate)
if sDateTime <> "" then
     sTime = FormatDateTime(g_dtMaxTime, vbLongTime)
     .TextOut nDateXPos, nDateYPos, " Date : "& DateValue(sDateTime)
     .TextOut nDateXPos, nDateYPos + nLineHeight, " Time : " &  TimeValue(sTime)
end if
Any assistance you can provide to be able to set the position of the date/time TextOut values such that the date/time display values do not overwrite each other when changing the font size would be appreciated: The format that I am looking to present is:
Date: formatteddate Time: formattedtime
where the formatted date and times represent the regional date/time formats

Thank you,
Scott Small

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Mon Aug 16, 2004 8:39 am

Hi --
Any assistance you can provide to be able to set the position of the date/time TextOut values such that the date/time display values do not overwrite each other when changing the font size would be appreciated:
You could try using the ICanvas.TextWidth property (see TeeChart help for details) to calculate the width of the text in different fonts.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Post Reply