Page 1 of 1

[Solved] TextGadget text justification

Posted: Thu Jan 16, 2025 10:23 pm
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

Re: TextGadget text justification

Posted: Fri Jan 17, 2025 9:08 am
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.