determining the pixel space that a canvas.TextOut object use
Posted: 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 :
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
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
Date: formatteddate Time: formattedtime
where the formatted date and times represent the regional date/time formats
Thank you,
Scott Small