Text Alignment

BlitzPlus Forums/BlitzPlus Programming/Text Alignment

bushsolo(Posted 2004) [#1]
I need to create a TextArea or TextField with the text aligned to the right rather than the left, the text gadgets seem a bit limited and don't seem to have this option.


jfk EO-11110(Posted 2004) [#2]
I have never seen such an editable Text Area in a windiws App. I guess this is not part of the Windows abstract toolkit. I could be wrong. However, you can code it by your own relatively easy.

for i=0 to x
text 640-stringwidth(lin$(i)),i*16,lin$(i)
next


soja(Posted 2004) [#3]
Unfortunately I don't think Blitz (natively) allows you to right-justify text in textfields or textareas.

I thought you might be able to set the right-justify (ES_RIGHT) flag through the WinAPI, but it seems like you can only do it when you create the textbox. You can't modify it afterwards. So if you absolutely needed to, you could probably create your own with CreateWindowEx, but it wouldn't be a Blitz gadget, and you'd probably have to manage it yourself.

From MSDN:

Edit Control Styles

To create an edit control using the CreateWindow or CreateWindowEx function, specify the EDIT class, appropriate window style constants, and a combination of the following edit control styles. After the control has been created, these styles cannot be modified, except as noted.
...
...
...
ES_RIGHT
Windows 98/Me, Windows 2000/XP: Right aligns text in a single-line or multiline edit control.
Windows 95, Windows NT 4.0 and earlier: Right aligns text in a multiline edit control.




bushsolo(Posted 2004) [#4]
Soja the ES_RIGHT sounds like the plan, it isn't a editable textarea and would be aligned to the right when created and has been locked with..

SendMessage QueryObject(TEXscreen,1),EM_SETREADONLY,1,0

..to lock it without the area being greyed out, I presume the ES_RIGHT is used in the same fashion, could you please provide some more info on this as I'm a bit of a noob.


soja(Posted 2004) [#5]
...I presume the ES_RIGHT is used in the same fashion...

I don't think so. If I understand correctly, it can only be specified when the edit control (text area, text field) is created. In other words, we would like to:
a) CreateTextArea
b) Send ES_RIGHT message to TextArea to right justify itself
...but it doesn't work like that. (See the last sentence of the first paragraph in the MSDN quote.)

So you would have to create everything on your own, e.g.:
a) CreateWindowEx (WinAPI function, specify edit control and ES_RIGHT)...
...but then you wouldn't be able to use the associated Blitz commands.

Note that I haven't really experimented with any of this.