'I was a bit hasty my last example
'beleive it or not that was about the
'top and only reference and microsoft.com
'It is 16 bit and has been replaced!
'by GetTextExtentPoint32 modifed at least
'half a dozen times with alias names
'hope this helps
'I recommend Win32 SDK Online Help
'from MSDN
'Example 1
'CurrentX
'appears to be assigned just like any other variable
OpenW 1
'documentation says right bottom should be top right
CurrentX = 0
CurrentY = 0
Text CurrentX, CurrentY, "Hallo..ooh"
CurrentX = 60
CurrentY = 100
Text CurrentX, CurrentY, "Hallo..ooh"
With Win_1
'center of circle CurrentX is text left CurrentX
CurrentX = 60
CurrentY = 100
Circle CurrentX, CurrentY, 60
EndWith
MsgBox "Press a key to exit"
CloseW 1
'Example 2
'GetTextExtentPoint32
'The GetTextExtentPoint32
'function computes the width and height of the
'specified string of text. This function supersedes
'the GetTextExtentPoint function.
'strangely there is no more GetTextExtentPoint32
'in my gdi32.Dll
'but this appears to work in gfa basic
'GetTextExtent '16 bit
'GetTextExtentPoint 'win 95 win 32
'GetTextExtentPoint32 'corrected again 32 bit
'superceded
'Alais GetTextExtentPoint32A
'Alais GetTextExtentPoint32W
'Alais GetTextExtentPoint32I
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
EndType
Type SIZE
cx As Long
cy As Long
EndType
Local TxtSz As SIZE
Local ret As Long
Local a$, b%
OpenW 1
a$ = "Hello"
' GetTextExtentPoint32(long handle to device context,
' long pointer to string, int length of string,
' pointer to size structure)
Text 10, 10, a$
Text 10, 30, "characters=" + Str(Len(a$))
ret = GetTextExtentPoint32(Win_1.hDC, V:a$, Len(a$), V:TxtSz)
Text 10, 50, "height=" + Str(TxtSz.cy)
Text 10, 70, "length=" + Str(TxtSz.cx)
a$ = "HelloHello"
Text 10, 110, a$
Text 10, 130, "characters=" + Str(Len(a$))
ret = GetTextExtentPoint32(Win_1.hDC, V:a$, Len(a$), V:TxtSz)
Text 10, 150, "height=" + Str(TxtSz.cy)
Text 10, 170, "length=" + Str(TxtSz.cx)
With Win_1
.AutoRedraw = True 'for paint redraw on graphics
.Font.Bold = True 'font properties
.Font.Italic = True
.Font.Name = "Arial"
.Font.Strikethrough = False
.Font.Underline = False
.Font.Size = 12
.ForeColor = RGB(0, 255, 0)
EndWith
Local Win1Rect As RECT
~GetWindowRect(Win_1.hWnd, Win1Rect)
Local WidthPixels = Win1Rect.Right - Win1Rect.Left
Text 10, 230, "characters=" + Str(Len(a$))
ret = GetTextExtentPoint32(Win_1.hDC, V:a$, Len(a$), V:TxtSz)
Text 10, 250, "height=" + Str(TxtSz.cy)
Text 10, 270, "length=" + Str(TxtSz.cx)
Text 10, 290, "window width=" + Str(WidthPixels)
Local MidPoint = (WidthPixels / 2) - (TxtSz.cx / 2)
Text MidPoint, 210, a$
Color RGB(255, 0, 0)
Text 10, 340, "Press a key to exit"
KeyGet b%
CloseW 1