Author Topic: text alignment functionality in canvas  (Read 4199 times)

venkat0249

  • Newbie
  • *
  • Posts: 22
text alignment functionality in canvas
« on: September 27, 2011, 05:18:38 PM »
is it possible to align text in canvas? means "align left","align right","centered" like that....Text align command is there for fields,listboxes, text box, but for canvas is there any such command? if not can we avail that functionality (text alignment) by writing a code specially?

tigabyte

  • Administrator
  • Newbie
  • *****
  • Posts: 54
Re: text alignment functionality in canvas
« Reply #1 on: September 28, 2011, 07:54:02 AM »
The canvases don't have an alignment command but the CanvasTextWidthFN function returns the width of the specified text. With this function and knowledge of the canvas width you could align your text. I'll let you have fun working it out for centering.

Code: [Select]
@ Right align for canvas 1
Local text,twidth,cwidth,xpos

Put CanvasWidthFN(1) into cwidth

Put 'Hello World' into text
Put CanvasTextWidthFN(1,text) into twidth

@ align right
Put cwidth into xpos
Subtract twidth from xpos
CanvasDrawText(1,text,20,xpos)

I haven't ran this code so there might be some typos.

venkat0249

  • Newbie
  • *
  • Posts: 22
Re: text alignment functionality in canvas
« Reply #2 on: September 28, 2011, 02:05:01 PM »
thank u...i got u... ;)