1. Right Justify in a Window
- Posted by doncole2009 Jun 09, 2009
- 742 views
- Last edited Jun 10, 2009
Hello Everybody,
Can anybody show how to right justify text in a window using mPuts or mPrint?
I can do it easily in a dos window with printf. But when I try mPuts or mPrint in a win32lib window it does come out right.
I've spent hours on this and am not getting anywhere. I think it has something to do with using getTextWidth().
Any help appreciated.
Don Cole
2. Re: Right Justify in a Window
- Posted by DerekParnell (admin) Jun 09, 2009
- 740 views
- Last edited Jun 10, 2009
doncole2009 said...
Can anybody show how to right justify text in a window using mPuts or mPrint?
Something along the lines of this (this is from memory BTW)
integer textsize = getTextWidth(yourtext) sequence boxsize = getClientSize(yourcontrol) integer rightmargin = floor(getTextWidth("M") / 2) -- I think [2] is width of control integer col = boxsize[2] - textsize - rightmargin wPuts(yourcontrol, {row, col, yourtext})
3. Re: Right Justify in a Window
- Posted by doncole2009 Jun 10, 2009
- 749 views
Thanks Derek,
After sleeping on it this is what I came up with.
global procedure justifyRight(integer id,integer col,integer row,sequence text) integer width width=getTextWidth(id,text) wPuts({id,col-width,row},text) end procedure
It's so simple I could just scream.
I hate it when I get hung up all day on something so easy.
Don Cole