Is there any way to change the properties of these gadgets, for example, left/right/center alignment of text, after they have already been created?
I have tried various combinations of #ES_RIGHT with SetWindowLong_ and Sendmessage_ but since I know absolutely nothing about Windows API calls and am fumbling in the dark, it's not surprising that I've been unsuccessful.
Change StringGadget or TextGadget property after creation?
Even through the API? Visual Basic manages to allow the TextAlign property to be changed at any time on the fly, so there must be a way that it is accomplishing that..?srod wrote:It is not possible to change the alignment of a string gadget after it is initially set. Not sure about text gadgets but I would suspect not.
I take it back!

Code: Select all
If OpenWindow(0, 0, 0, 270, 160, "StringGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(0, 10, 10, 250, 20, "Should be right justified!", #ES_CENTER)
ButtonGadget(1, 10, 40, 100, 20, "RIGHT JUSTIFY!")
Repeat
eventID = WaitWindowEvent()
Select eventID
Case #PB_Event_Gadget
Select EventGadget()
Case 1
SetWindowLong_(GadgetID(0), #GWL_STYLE, GetWindowLong_(GadgetID(0), #GWL_STYLE)&~#ES_CENTER|#ES_RIGHT)
InvalidateRect_(GadgetID(0), 0, 1)
EndSelect
EndSelect
Until eventID = #PB_Event_CloseWindow
EndIf
I may look like a mule, but I'm not a complete ass.
Ahhh, then my memory isn't as bad as I figured!!! Just tested on XP and it doesn't work; works on Vista!
I do recall reading some time ago that once an edit control had been created and the alignment set, that it could not be altered. This was before the advent of Vista of course.
Perhaps I am not going nuts after all!

I do recall reading some time ago that once an edit control had been created and the alignment set, that it could not be altered. This was before the advent of Vista of course.
Perhaps I am not going nuts after all!

I may look like a mule, but I'm not a complete ass.
With my EsGRID control, I create 3 edit controls for use when editing text cells; one for left justification, center and right justifcation. I move the controls off-screen when they are not in use etc. I prefered this option over continually destroying and recreating a single edit control as the text justification changes between cells etc. A pain, and like yourself I was disappointed to find that you could not alter an edit control's text alignment after it had been set etc. (at least on versions of Windows prior to Vista).
It does seem a strange 'omission'.
It does seem a strange 'omission'.
I may look like a mule, but I'm not a complete ass.