Bill,

Your "text on layout window" solution is much better than mine. Thanks.
Sorry, I have no other suggestions on your text in mapper problem. I have
never been sucessful at manipulating Mapinfo with Win32 API calls.

- Brad

> -----Original Message-----
> From: Bill Thoen [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, January 03, 2000 3:57 PM
> To:   Brad Mathews
> Cc:   MapInfo-L
> Subject:      Re: MI Question for MB and Win API experts
> 
> Actually, I have figured out the "text on layout window" problem
> without having to resort to API calls. An app that demonstrates
> how to do it (and includes MB source) is available from
> http://www.directionsmag.com/tools/default.asp?a=file&id=203. The
> trick is to lay down the text somewhere convenient, and then read
> the MBR values and move it to exactly where you want it. This
> works in layouts because the coordsys is cartesian, but in a
> mapper you have the added problem of projections and spherical
> coordinate systems, and so the MBR varies depending on where you
> place the text.
> 
> And thanks for the good tip for Interated Mapping approaches
> though...
> 
> Brad Mathews wrote:
> > 
> > BIll,
> > 
> > I have not attempted what you are trying from within MB, but I have
> solved
> > similar problems from within VB using Integrated Mapping.
> > 
> > A Mapinfo Layout window has no way of centering text from MB (at least
> it
> > has never worked correctly). I was able to get centered text in a Layout
> > window by using VB's Printer.TextWidth function to get the width of the
> text
> > and decide where to place it (my function below). Unfortunately, this is
> not
> > as precise as I would like it to be. If you also changed the default
> printer
> > to the one you are going to use on your layout, it would help, but still
> not
> > be perfect.
> > 
> > - Brad
> > 
> > Public Sub TextCenter(ByVal Address As String, x1 As Single, x2 As
> Single)
> > 
> > Dim A As Integer, b As Integer
> > Dim W As Single, nl As Integer
> > 
> > ' Set the font attributes I am using
> > Printer.Font = "Times New Roman"
> > Printer.FontSize = 18
> > Printer.FontBold = True
> > Printer.FontItalic = True
> > ' Use inches
> > Printer.ScaleMode = 5
> > 
> > ' If there is a newline in the address then get the longest line
> > nl = InStr(Address, "\n")
> > If nl > 0 Then
> >     If nl < (Len(Address) / 2) Then
> >         Address = Mid$(Address, nl + 2)
> >     Else
> >         Address = left$(Address, nl - 1)
> >     End If
> > End If
> > 
> > ' get the width of the line in inches. Cycling the bold attribute is a
> > workaround to a VB5 bug.
> > ' Haven't tested VB6 to see if bug is gone.
> > W = Printer.TextWidth("Hello THere")
> > Printer.FontBold = False
> > W = Printer.TextWidth("Hello")
> > Printer.FontBold = True
> > W = Printer.TextWidth(Address)
> > 
> > ' Get the start and ending locations on the page in inches
> > x1 = ((Printer.ScaleWidth - W) / 2) + 0.2
> > x2 = ((Printer.ScaleWidth - W) / 2) + W + 0.2
> > 
> > End Sub
> ----------------------------------------------------------------------
> To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
> "unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

Reply via email to