ListIconGadget Header with Toggle columns
Posted: Thu Jul 25, 2019 1:16 pm
Hello
Search a solution for toogle columns in a header of listicongadget.
if pressed second column then colored to blue and the other should to red.
Here is my startcode:
Please help
Lite
Search a solution for toogle columns in a header of listicongadget.
if pressed second column then colored to blue and the other should to red.
Here is my startcode:
Code: Select all
#ColoredColumn = 0
Global col=0
#HeaderTextColor = #Blue
#LVM_GETHEADER = #LVM_FIRST + 31
Define DefaultListIconCallback.I
Procedure CustomListIconCallback(WindowHandle.I, Msg.I, WParam.I, LParam.I)
Shared DefaultListIconCallback.I
Protected *NMCUSTOMDRAW.NMCUSTOMDRAW
Protected *NMHDR.NMHDR
Protected Result.I
Result = CallWindowProc_(DefaultListIconCallback, WindowHandle.I, Msg.I,
WParam.I, LParam.I)
If Msg = #WM_NOTIFY
*NMHDR = LParam
*NMCUSTOMDRAW = LParam
SetTextColor_(*NMCUSTOMDRAW\hdc, #Red)
If *NMHDR\code = #NM_CUSTOMDRAW
*NMCUSTOMDRAW = LParam
Select *NMCUSTOMDRAW\dwDrawStage
Case #CDDS_PREPAINT
Result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
If *NMCUSTOMDRAW\dwItemSpec = col
SetTextColor_(*NMCUSTOMDRAW\hdc, #HeaderTextColor)
Else
SetTextColor_(*NMCUSTOMDRAW\hdc, #Red)
EndIf
If *NMCUSTOMDRAW\uItemState & #CDIS_SELECTED
col=*NMCUSTOMDRAW\dwItemSpec
EndIf
EndSelect
EndIf
EndIf
ProcedureReturn Result
EndProcedure
OpenWindow(0, 200, 100, 400, 150, "ListIconGadget with colored header text")
ListIconGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20, "Name", 110, #PB_ListIcon_GridLines)
AddGadgetColumn(0, 1, "Address", 150)
AddGadgetColumn(0, 2, "test", 120)
AddGadgetItem(0, -1, "Harry Rannit" + #LF$ +
"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit" + #LF$ +
"130 PureBasic Road, BigTown, CodeCity")
AddGadgetItem(0, -1, "Didi Foundit" + #LF$ +
"321 Logo Drive, Mouse House, Downtown")
DefaultListIconCallback = SetWindowLongPtr_(GadgetID(0), #GWL_WNDPROC,
@CustomListIconCallback())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Lite