Wenn Du die Panel-Items eh schon selbst zeichnest, müsstest
Du den Panel-Hintergrund im Callback des PanelGadgets bei der
Nachricht #WM_ERASEBKGND ändern können.
Code: Alles auswählen
;
; Danilo, April 2011, PB 4.51 (x86)
;
Global panel
Global oldWndProc, oldPanelWndProc
Global panelBackColorBrush = CreateSolidBrush_(RGB($00,$00,$FF))
Global tabBackColorBrush = CreateSolidBrush_(RGB($FF,$80,$00))
Global tabTextColor = RGB($FF,$FF,$00)
Procedure WindowProc(hWnd,msg,wParam,lParam)
Select msg
Case #WM_DRAWITEM
*dis.DRAWITEMSTRUCT = lParam
If *dis
; Tab item background
FillRect_(*dis\hDC,*dis\rcItem,tabBackColorBrush)
; Tab item text background mode = transparent
SetBkMode_(*dis\hdc,#TRANSPARENT)
; Tab item text color
SetTextColor_(*dis\hDC,tabTextColor)
; get and draw the Tab item text
txt$ = GetGadgetItemText(panel,*dis\itemID)
DrawText_(*dis\hDC,txt$,-1,*dis\rcItem,#DT_CENTER|#DT_VCENTER|#DT_SINGLELINE)
EndIf
ProcedureReturn 1
EndSelect
ProcedureReturn CallWindowProc_(oldWndProc,hWnd,msg,wParam,lParam)
EndProcedure
Procedure PanelProc(hWnd,msg,wParam,lParam)
Select msg
Case #WM_ERASEBKGND
GetClientRect_(hWnd,@bckRect.RECT)
FillRect_(wParam,@bckRect,panelBackColorBrush)
ProcedureReturn 1
EndSelect
ProcedureReturn CallWindowProc_(oldPanelWndProc,hWnd,msg,wParam,lParam)
EndProcedure
mainWindow = OpenWindow(#PB_Any,0,0,800,600,"PanelGadget",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
oldWndProc = SetWindowLong_(WindowID(mainWindow),#GWL_WNDPROC,@WindowProc())
panel = PanelGadget(#PB_Any,10,10,780,580)
oldPanelWndProc = SetWindowLong_(GadgetID(panel),#GWL_WNDPROC,@PanelProc())
SetWindowLong_(GadgetID(panel),#GWL_STYLE,#TCS_OWNERDRAWFIXED|GetWindowLong_(GadgetID(panel),#GWL_STYLE))
AddGadgetItem (panel, -1, "Panel 1")
ButtonGadget(#PB_Any, 10, 10, 80, 25,"Button 1")
AddGadgetItem (panel, -1, "Panel 2 has a button")
ButtonGadget(#PB_Any, 10, 10, 80, 25,"Button 2")
AddGadgetItem (panel, -1, "P3")
CloseGadgetList()
SetWindowColor(mainWindow,RGB($FF,$FF,$00))
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
DeleteObject_(panelBackColorBrush)
DeleteObject_(tabBackColorBrush)
Wenn Du die Reiterleiste und den eigentlichen Tab-Bereich mit
unterschiedlichen Hintergrundfarben darstellen möchtest, kannst
Du das bei #WM_ERASEBKGND in PanelProc() anpassen, oder
auch ein Bild zeichnen etc.
EDIT:
Nur mit SetClassLong_(), ohne subclassing für das PanelGadget:
Code: Alles auswählen
;
; Danilo, April 2011, PB 4.51 (x86)
;
Global panel
Global oldWndProc
Global panelBackColorBrush = CreateSolidBrush_(RGB($00,$00,$FF))
Global tabBackColorBrush = CreateSolidBrush_(RGB($FF,$80,$00))
Global tabTextColor = RGB($FF,$FF,$00)
Procedure WindowProc(hWnd,msg,wParam,lParam)
Select msg
Case #WM_DRAWITEM
*dis.DRAWITEMSTRUCT = lParam
If *dis
; Tab item background
FillRect_(*dis\hDC,*dis\rcItem,tabBackColorBrush)
; Tab item text background mode = transparent
SetBkMode_(*dis\hdc,#TRANSPARENT)
; Tab item text color
SetTextColor_(*dis\hDC,tabTextColor)
; get and draw the Tab item text
txt$ = GetGadgetItemText(panel,*dis\itemID)
DrawText_(*dis\hDC,txt$,-1,*dis\rcItem,#DT_CENTER|#DT_VCENTER|#DT_SINGLELINE)
EndIf
ProcedureReturn 1
EndSelect
ProcedureReturn CallWindowProc_(oldWndProc,hWnd,msg,wParam,lParam)
EndProcedure
mainWindow = OpenWindow(#PB_Any,0,0,800,600,"PanelGadget",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
oldWndProc = SetWindowLong_(WindowID(mainWindow),#GWL_WNDPROC,@WindowProc())
panel = PanelGadget(#PB_Any,10,10,780,580)
SetClassLong_(GadgetID(panel),#GCL_HBRBACKGROUND,panelBackColorBrush)
SetWindowLong_(GadgetID(panel),#GWL_STYLE,#TCS_OWNERDRAWFIXED|GetWindowLong_(GadgetID(panel),#GWL_STYLE))
AddGadgetItem (panel, -1, "Panel 1")
ButtonGadget(#PB_Any, 10, 10, 80, 25,"Button 1")
AddGadgetItem (panel, -1, "Panel 2 has a button")
ButtonGadget(#PB_Any, 10, 10, 80, 25,"Button 2")
AddGadgetItem (panel, -1, "P3")
CloseGadgetList()
SetWindowColor(mainWindow,RGB($FF,$FF,$00))
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
DeleteObject_(panelBackColorBrush)
DeleteObject_(tabBackColorBrush)