If looking for cross-platform code using platform-specific API functions you may take a look into
this posting in which I have collected links to a lot of examples. There you would have found already an example on how to right align a text in the StringGadget. I have modified it below to center the text:
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, "StringGadget with centered text", #PB_Window_SystemMenu)
StringGadget(0, 20, 20, 240, 21, "Centered text")
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
gtk_entry_set_alignment(GadgetID(0), 0.5)
CompilerCase #PB_OS_MacOS
CocoaMessage(0, GadgetID(0), "setAlignment:", 2)
CompilerCase #PB_OS_Windows
If OSVersion() > #PB_OS_Windows_XP
SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) & $FFFFFFFC | #ES_CENTER)
Else
StringGadget(0, 60, 20, 150, 21, "Centered text", #ES_CENTER)
EndIf
CompilerEndSelect
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
You will find another link to a ListIconGadget example which ensures the visibility of a selected line or scrolls it to the center of the ListIconGadget. It would be nice if you could post a simple runnable Windows example which demonstrates exactly what you want to achieve and I will try to add the Linux and MacOS part...
It would be nice and helpful if a mod or admin would move my above mentioned posting from the Mac OSX subforum to the Tricks 'n' Tips subforum (and ideally even make it sticky)...
