Before I attempt to use a Windows API
function, does anyone know how to center a text object in a layout window
using MapBasic. The "create text" statement allows the
placement
point to be only in the upper left corner of
the text object. I have tried to use objectGeography function to calculate
the extents of the text object, but it gives incorrect results. Next, I
tried to calculate the length of the string based on the number of
characters, but failed due to the variable character size of Windows
fonts.
Daniel,
Here is a function that determines the
length of a text string in a given font, using a
layout.
You can simply use that value for recreating
the string at the X position half that length to the left of the centering
position.
I
have used that procedure extensively in reshaping SCALBAR3 (or something
very close) that is available on the ftp-site. Now LAYSCALE (that draws
scale bars in a layout, with automatic scale determination) offers many text
alignment options. If you would like to see it, drop me a
line.