Seite 1 von 1
Statusbar Textfarbe ändern?
Verfasst: 07.12.2007 21:19
von pebo
Hallo zusammen,
gibt es eine Möglichkeit die Textfarbe in einer Statusbar zu ändern?
Gruss
Peter
Verfasst: 07.12.2007 22:00
von scholly
Suchen im englischen Forum ist meine erste Idee, wenn ich hier nix finde. Guckst Du
in diesen Thread oder
hier.
Im CodeArchiv ist auch ein Beispielcode:
Code: Alles auswählen
; German forum: http://www.purebasic.fr/german/archive/viewtopic.php?t=3001&highlight=
; Author: isidoro (updated for PB4.00 by blbltheworm)
; Date: 11. December 2003
; OS: Windows
; Demo: No
#SB_SETBKCOLOR = $2001
color=RGB($FF,$FF,$AA)
#MainWin=0
MainWinX=100
MainWinY=150
MainWinW=400
MainWinH=200
hwnd=OpenWindow(#MainWin, MainWinX, MainWinY, MainWinW, MainWinH, "Test Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
statuswnd= CreateStatusBar(0,WindowID(#MainWin))
If statuswnd
AddStatusBarField(500)
EndIf
If hwnd
; OleTranslateColor_(color,0,@color); Falls Farbwerte umgewandelt werden müssen
SendMessage_(statuswnd,#SB_SETBKCOLOR ,0,color)
StatusBarText(0,0,"Das ist die tolle bunte Leiste ",#PB_StatusBar_Center )
Repeat
EventID.l = WindowEvent()
If EventID
Select EventID
Case #PB_Event_CloseWindow
Quit=1
EndSelect
Else
Delay(10)
EndIf
Until Quit
EndIf
End
Vielleicht kannst Du da ja was abwandeln.
PureCOLOR scheint nur für Gadgets zu sein.
hdh... scholly
Verfasst: 07.12.2007 22:17
von Fluid Byte
So gehts, XP kompatibel:
Code: Alles auswählen
Structure ODSBTEXT
szText.l
clrFront.l
clrBack.l
EndStructure
Procedure WindowCallback(hWnd.l,uMsg.l,wParam.l,lParam.l)
Select uMsg
Case #WM_DRAWITEM
Protected *lpdis.DRAWITEMSTRUCT = lParam
If *lpdis\hWndItem = StatusBarID(0)
Protected *osbt.ODSBTEXT = *lpdis\itemData
SetTextColor_(*lpdis\hDC,*osbt\clrFront)
If *osbt\clrBack = -1
SetBkMode_(*lpdis\hDC,1)
Else
SetBkColor_(*lpdis\hDC,*osbt\clrBack)
EndIf
SendMessage_(*lpdis\hwndItem,#SB_GETBORDERS,0,aBorders.RECT)
InflateRect_(*lpdis\rcItem,-aBorders\right / 2,0)
DrawText_(*lpdis\hDC,*osbt\szText,-1,*lpdis\rcItem,#DT_SINGLELINE | #DT_VCENTER)
EndIf
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(0,0,0,350,100,"Custom Statusbar Text Colors",#WS_OVERLAPPEDWINDOW | 1)
SetWindowCallback(@WindowCallback())
CreateStatusBar(0,WindowID(0))
AddStatusBarField(100) : AddStatusBarField(100) : AddStatusBarField(100)
osbt1.ODSBTEXT
osbt1\szText = @"Statusbar Field #1"
osbt1\clrFront = #Green
osbt1\clrBack = #Black
SendMessage_(StatusBarID(0),#SB_SETTEXT,0 | #SBT_OWNERDRAW,osbt1)
osbt2.ODSBTEXT
osbt2\szText = @"Statusbar Field #2"
osbt2\clrFront = #Yellow
osbt2\clrBack = #Red
SendMessage_(StatusBarID(0),#SB_SETTEXT,1 | #SBT_OWNERDRAW,osbt2)
osbt3.ODSBTEXT
osbt3\szText = @"Statusbar Field #3"
osbt3\clrFront = #Cyan
osbt3\clrBack = #Blue
SendMessage_(StatusBarID(0),#SB_SETTEXT,2 | #SBT_OWNERDRAW,osbt3)
While WaitWindowEvent() ! 16 : Wend
[edit]
Du kannst die Hintergundfarbe transparent machen wenn du "\clrBack" auf -1 setzt.
[/edit]
Verfasst: 08.12.2007 03:53
von pebo
Ich danke euch beiden für die Hilfe
Gruss
Peter