Change text box X & Y position at runtime

I’m having a mental moment for some reason …
I have a string, it’s placed on a window as a text field. I want the text field to always be in the lower right corner of the window as the window is resized.
So on the Event:Sized event of the window I need to change the X & Y position of the text box.
But whether I use “text{Prop:XPos}” or “?text{Prop:XPos}” my text box never changes position. The window has IMM,AUTO attributes, but changing them doesn’t seem to make a difference. Neither does calling Display after I change the properties.
What am I forgetting?

This seems to work OK.

Window WINDOW('Caption'),AT(,,395,224),GRAY,IMM,FONT('Microsoft Sans Serif',8),RESIZE
    ?Text1{PROP:Text} = 'Howdy!'
      CASE EVENT()
      OF EVENT:sized
        ?Text1{PROP:XPos} = 0{PROP:Width}  - ?Text1{PROP:Width}  - 4
        ?Text1{PROP:YPos} = 0{PROP:Height} - ?Text1{PROP:Height} - 4
1 Like

Are you using MakeOver from CapeSoft?

If you do, maybe try a ThisMakeover.Refresh(mo:WinType) after the position change.

Thanks Jeff, let me go figure out what I’m doing wrong :slight_smile:

OK, the USE property is different.
I was using “USE(Glo:TextBox)” and you have “USE(?Text1)” and use Prop:Text to update the window
I can figure it out from here, thanks!

Not sure that’s actually relevant.

You can certainly USE(Glo:TextBox), but you would refer to its FEQ as ?Glo:Textbox in code.

Or you could specify the FEQ explicitly in the USE itself, different than the variable that it uses.

You can certainly USE(Glo:TextBox), but you would refer to its FEQ as ?Glo:Textbox in code.

That’s what I did to start with, but it didn’t work. But, this is C6 :slight_smile:
It’s OK, I’m on to different things now using WHAT & WHO for the first time in 20 years…

1 Like

FYI you can use GetPosition / SetPostion(feq,xpos,ypos,width,height) to get/set all at once. You can omit any you do not want e.g. SetPosition(?text,newX,newY). The Window FEQ is Zero.

This post has a routine with some example code that moves controls based on window size.

IIRC if you are using PROP:DeferMove you must use PROPs for it to work.

1 Like