1. Right Justify in a Window

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

new topic     » topic index » view message » categorize

2. Re: Right Justify in a Window

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}) 

new topic     » goto parent     » topic index » view message » categorize

3. Re: Right Justify in a Window

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu