Unfortunately it's a little bit more complicated. In Windows XP the alignment is only possible on creation of the StringGadget. Beginning with Windows Vista it's possible to change the alignment of a StringGadget's content dynamically:Fred wrote:Using other gadget flags is not supported, use SetWindowLong_() on Windows if you want to change the style
http://forum.purebasic.com/english/view ... 13&t=36853
Try the following cross-platform code which I tested on Windows XP x86 SP3, Windows 7 x86 SP1, Kubuntu 13.04 x86 and Linux Mint 15 x86 Cinnamon. It redefines the StringGadget on Windows XP with the attribute #ES_RIGHT and changes the alignment dynamically on Windows Vista, Windows 7, Linux and MacOS X:
Code: Select all
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
ImportC ""
gtk_entry_set_alignment(Entry.I, XAlign.F)
EndImport
CompilerEndIf
OpenWindow(0, 100, 100, 280, 70, "Right-aligned StringGadget", #PB_Window_SystemMenu)
StringGadget(0, 60, 20, 150, 21, "123")
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
gtk_entry_set_alignment(GadgetID(0), 1)
CompilerCase #PB_OS_MacOS
CocoaMessage(0, GadgetID(0), "setAlignment:", 1)
CompilerCase #PB_OS_Windows
If OSVersion() > #PB_OS_Windows_XP
SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) & $FFFFFFFC | #ES_RIGHT)
Else
StringGadget(0, 60, 20, 150, 21, "123", #ES_RIGHT)
EndIf
CompilerEndSelect
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow