[Solved] TextGadget text justification

Everything else that doesn't fall into one of the other PB categories.
k3pto
User
User
Posts: 87
Joined: Sat Jan 17, 2015 5:24 pm

[Solved] TextGadget text justification

Post by k3pto »

Is it possible to change the justification of a TextGadget dynamically? The only forum entries I found say no, but they are 10 yrs old.

Thank you Shardik, that works. I did shrink the code for Windows only:

Procedure Justify ( WhichGadget, Justification )
Define i

WhichGadget = GadgetID(WhichGadget)
i = GetWindowLongPtr_(WhichGadget, #GWL_STYLE)
Select Justification
Case -1 : i & ~#SS_CENTER & ~#SS_RIGHT | #SS_LEFT
Case 0 : i & ~#SS_LEFT & ~#SS_RIGHT | #SS_CENTER
Case 1 : i & ~#SS_LEFT & ~#SS_CENTER | #SS_RIGHT
EndSelect
SetWindowLongPtr_(WhichGadget, #GWL_STYLE, i )
InvalidateRect_(WhichGadget, 0, #True)
EndProcedure
Last edited by k3pto on Sun Jan 19, 2025 1:40 am, edited 1 time in total.
User avatar
Shardik
Addict
Addict
Posts: 2060
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: TextGadget text justification

Post by Shardik »

k3pto wrote: Thu Jan 16, 2025 10:23 pm Is it possible to change the justification of a TextGadget dynamically? The only forum entries I found say no, but they are 10 yrs old.
You didn't mention your operating system. Therefore you may try this cross-platform example which demonstrates how to toggle the text alignment in a TextGadget dynamically between left, centered and right.
Post Reply