Listicongadget column header color
Listicongadget column header color
Hi, can anyone tell me, how to set Listicongadget column header color, PureCOLOR_SetColumnHeaderColor do nothing?
Karu
Karu
Re: Listicongadget column header color
Hmm, no answers, how you people color your columnheaders in listicongadget?
Re: Listicongadget column header color
Code: Select all
#LVM_GETHEADER = #LVM_FIRST + 31
; Globals
Global oldListIconCallback, hHeader, brush
brush=CreateSolidBrush_(#Yellow)
Procedure SubclassedListIcon(hWnd, uMsg, wParam, lParam)
Protected hdi.hd_item
result = CallWindowProc_(oldListIconCallback, hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_NOTIFY
*pnmh.NMHDR = lparam
;--> Get handle to ListIcon header control
If *pnmh\code = #NM_CUSTOMDRAW
*pnmcd.NMCUSTOMDRAW = lparam
;--> Determine drawing stage
Select *pnmcd\dwDrawStage
Case #CDDS_PREPAINT
result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
text$=GetGadgetItemText(0, -1, *pnmcd\dwItemSpec)
If *pnmcd\uItemState & #CDIS_SELECTED
DrawFrameControl_(*pnmcd\hdc, *pnmcd\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH|#DFCS_PUSHED)
*pnmcd\rc\left+2 : *pnmcd\rc\top+1
Else
DrawFrameControl_(*pnmcd\hdc, *pnmcd\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH)
EndIf
*pnmcd\rc\bottom-1 : *pnmcd\rc\right-1
SetBkMode_(*pnmcd\hdc,#TRANSPARENT)
If *pnmcd\dwItemSpec&1
FillRect_(*pnmcd\hdc, *pnmcd\rc, brush)
SetTextColor_(*pnmcd\hdc, #Blue)
Else
FillRect_(*pnmcd\hdc, *pnmcd\rc, brush)
SetTextColor_(*pnmcd\hdc, #Red)
EndIf
If *pnmcd\rc\right>*pnmcd\rc\left
DrawText_(*pnmcd\hdc, @text$, Len(text$), *pnmcd\rc, #DT_CENTER|#DT_VCENTER|#DT_SINGLELINE|#DT_END_ELLIPSIS)
EndIf
result = #CDRF_SKIPDEFAULT
EndSelect
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 100, 100, 415, 300, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 405, 200, "col 0", 50, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
hHeader = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
;Subclass ListIcon so we can customdraw the header text
oldListIconCallback = SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @SubclassedListIcon())
;Add 10 more columns.
For i = 1 To 10
AddGadgetColumn(0, i, "col "+Str(i), 50)
Next
;Add some data
For b=0 To 99; Add 100 rows.
AddGadgetItem(0,-1,"")
Next
For i = 0 To 99
For j = 0 To 50
SetGadgetItemText(0,i,Str(i+j),j)
Next j
Next i
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
DeleteObject_(brush)
EndIf
I may look like a mule, but I'm not a complete ass.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Listicongadget column header color
Beating me now, are you? Is that how it is? I should call for an umpire ruling though, that looks suspiciously like code ripped from ESGrid. My forensic scientists tell me that you wrote ESGrid before #LVM_GETHEADER became a native constant and so your first line gives it away.
Btw, very nice piece of code you wrote there.
Btw, very nice piece of code you wrote there.

BERESHEIT
Re: Listicongadget column header color
Yes some old code I had lying around. Not sure if it came before EsGRID or not? 

I may look like a mule, but I'm not a complete ass.
Re: Listicongadget column header color
Thanks, but how to color 'undefined' header area, if your example have only 3 columns, then the undefined column area still grey?srod wrote:Code: Select all
#LVM_GETHEADER = #LVM_FIRST + 31 ; Globals Global oldListIconCallback, hHeader, brush brush=CreateSolidBrush_(#Yellow) Procedure SubclassedListIcon(hWnd, uMsg, wParam, lParam) Protected hdi.hd_item result = CallWindowProc_(oldListIconCallback, hWnd, uMsg, wParam, lParam) Select uMsg Case #WM_NOTIFY *pnmh.NMHDR = lparam ;--> Get handle to ListIcon header control If *pnmh\code = #NM_CUSTOMDRAW *pnmcd.NMCUSTOMDRAW = lparam ;--> Determine drawing stage Select *pnmcd\dwDrawStage Case #CDDS_PREPAINT result = #CDRF_NOTIFYITEMDRAW Case #CDDS_ITEMPREPAINT text$=GetGadgetItemText(0, -1, *pnmcd\dwItemSpec) If *pnmcd\uItemState & #CDIS_SELECTED DrawFrameControl_(*pnmcd\hdc, *pnmcd\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH|#DFCS_PUSHED) *pnmcd\rc\left+2 : *pnmcd\rc\top+1 Else DrawFrameControl_(*pnmcd\hdc, *pnmcd\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH) EndIf *pnmcd\rc\bottom-1 : *pnmcd\rc\right-1 SetBkMode_(*pnmcd\hdc,#TRANSPARENT) If *pnmcd\dwItemSpec&1 FillRect_(*pnmcd\hdc, *pnmcd\rc, brush) SetTextColor_(*pnmcd\hdc, #Blue) Else FillRect_(*pnmcd\hdc, *pnmcd\rc, brush) SetTextColor_(*pnmcd\hdc, #Red) EndIf If *pnmcd\rc\right>*pnmcd\rc\left DrawText_(*pnmcd\hdc, @text$, Len(text$), *pnmcd\rc, #DT_CENTER|#DT_VCENTER|#DT_SINGLELINE|#DT_END_ELLIPSIS) EndIf result = #CDRF_SKIPDEFAULT EndSelect EndIf EndSelect ProcedureReturn result EndProcedure If OpenWindow(0, 100, 100, 415, 300, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ListIconGadget(0, 5, 5, 405, 200, "col 0", 50, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection) hHeader = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0) ;Subclass ListIcon so we can customdraw the header text oldListIconCallback = SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @SubclassedListIcon()) ;Add 10 more columns. For i = 1 To 3 AddGadgetColumn(0, i, "col "+Str(i), 50) Next ;Add some data For b=0 To 99; Add 100 rows. AddGadgetItem(0,-1,"") Next For i = 0 To 99 For j = 0 To 50 SetGadgetItemText(0,i,Str(i+j),j) Next j Next i Repeat Until WaitWindowEvent() = #PB_Event_CloseWindow DeleteObject_(brush) EndIf
Re: Listicongadget column header color
Have to subclass the header and intercept #WM_PAINT and #WM_ERASEBKGND etc. It is quite fiddly.
I may look like a mule, but I'm not a complete ass.
Re: Listicongadget column header color
Can you show me example please?srod wrote:Have to subclass the header and intercept #WM_PAINT and #WM_ERASEBKGND etc. It is quite fiddly.
Re: Listicongadget column header color
Nope.
Haven't the time I'm afraid... too tired right now. I did it with EsGRID; it's a case of determining the combined width of all columns and then filling the remaining area up to the right hand edge of the header control.

Haven't the time I'm afraid... too tired right now. I did it with EsGRID; it's a case of determining the combined width of all columns and then filling the remaining area up to the right hand edge of the header control.
I may look like a mule, but I'm not a complete ass.
Re: Listicongadget column header color
Workaround for srod coloring ListIcon Header code
Code: Select all
; Globals
Global oldListIconCallback, hHeader, brush
brush=CreateSolidBrush_(#Yellow)
Procedure SubclassedListIcon(hWnd, uMsg, wParam, lParam)
Protected hdi.hd_item
result = CallWindowProc_(oldListIconCallback, hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_NOTIFY
*pnmh.NMHDR = lparam
;--> Get handle to ListIcon header control
If *pnmh\code = #NM_CUSTOMDRAW
*pnmcd.NMCUSTOMDRAW = lparam
;--> Determine drawing stage
Select *pnmcd\dwDrawStage
Case #CDDS_PREPAINT
result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
text$=GetGadgetItemText(0, -1, *pnmcd\dwItemSpec)
If *pnmcd\uItemState & #CDIS_SELECTED
DrawFrameControl_(*pnmcd\hdc, *pnmcd\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH|#DFCS_PUSHED)
*pnmcd\rc\left+2 : *pnmcd\rc\top+1
Else
DrawFrameControl_(*pnmcd\hdc, *pnmcd\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH)
EndIf
*pnmcd\rc\bottom-1 : *pnmcd\rc\right-1
SetBkMode_(*pnmcd\hdc,#TRANSPARENT)
If *pnmcd\dwItemSpec&1
FillRect_(*pnmcd\hdc, *pnmcd\rc, brush)
SetTextColor_(*pnmcd\hdc, #Blue)
Else
FillRect_(*pnmcd\hdc, *pnmcd\rc, brush)
SetTextColor_(*pnmcd\hdc, #Red)
EndIf
GetClientRect_(GadgetID(0),r.RECT)
SendMessage_(GadgetID(0),#LVM_GETSUBITEMRECT,4,rc.RECT)
MoveWindow_(GadgetID(1),rc\right+6,5, r\right-rc\right+2,26,1)
;ResizeGadget(1,rc\right+6,#PB_Ignore, r\right-rc\right+2,#PB_Ignore)
If *pnmcd\rc\right>*pnmcd\rc\left
DrawText_(*pnmcd\hdc, @text$, Len(text$), *pnmcd\rc, #DT_CENTER|#DT_VCENTER|#DT_SINGLELINE|#DT_END_ELLIPSIS)
EndIf
result = #CDRF_SKIPDEFAULT
EndSelect
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 100, 100, 415, 300, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 405, 200, "col 0", 50, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines|#WS_CLIPSIBLINGS)
hHeader = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
;Subclass ListIcon so we can customdraw the header text
oldListIconCallback = SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @SubclassedListIcon())
;Add 10 more columns.
For i = 1 To 4
AddGadgetColumn(0, i, "col "+Str(i), 50)
Next
;Add some data
For b=0 To 99; Add 100 rows.
AddGadgetItem(0,-1,"")
Next
For i = 0 To 99
For j = 0 To 50
SetGadgetItemText(0,i,Str(i+j),j)
Next j
Next i
GetClientRect_(GadgetID(0),r.RECT)
SendMessage_(GadgetID(0),#LVM_GETSUBITEMRECT,4,rc.RECT)
TextGadget(1,rc\right+6,5,r\right-rc\right+2,26,"",#WS_BORDER)
SetGadgetColor(1, #PB_Gadget_BackColor, #Yellow)
SetWindowPos_(GadgetID(1),#HWND_TOP,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
DeleteObject_(brush)
EndIf
Egypt my love
Re: Listicongadget column header color
Thank you all