Listicongadget header color and resizing columns (Windows)
Posted: Mon Jan 13, 2025 2:39 pm
(For Windows API and subclassing wizards)
I'm trying to improve the looks of this dark listicongadget. How to fix the white patch? I'd like to make it black too.

I'm trying to improve the looks of this dark listicongadget. How to fix the white patch? I'd like to make it black too.

Code: Select all
Prototype.i DwmSetWindowAttribute(hWnd.i, dwAttribute.i, pvAttribute.i, cbAttribute.i)
#HeaderTextColor = $989898
#LVM_GETHEADER = #LVM_FIRST + 31
Define DefaultListIconCallback.I
Global bluebrush=CreateSolidBrush_($141414)
Procedure CustomListIconCallback(WindowHandle.I, Msg.I, WParam.I, LParam.I)
Shared hHeader, 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
If *NMHDR\code = #NM_CUSTOMDRAW
*NMCUSTOMDRAW = LParam
Select *NMCUSTOMDRAW\dwDrawStage
Case #CDDS_PREPAINT
Result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
hdi.hd_item
text$=Space(100)
hdi\mask = #HDI_TEXT
hdi\psztext = @text$
hdi\cchtextmax = Len(text$)
SendMessage_(hHeader, #HDM_GETITEM,*NMCUSTOMDRAW\dwItemSpec,hdi)
InflateRect_(*NMCUSTOMDRAW\rc,-1,-1)
SetBkMode_(*NMCUSTOMDRAW\hdc,#TRANSPARENT)
FillRect_(*NMCUSTOMDRAW\hdc, *NMCUSTOMDRAW\rc, bluebrush)
SetTextColor_(*NMCUSTOMDRAW\hdc, #HeaderTextColor)
DrawText_(*NMCUSTOMDRAW\hdc, @text$, Len(text$), *NMCUSTOMDRAW\rc, #DT_CENTER|#DT_VCENTER|#DT_END_ELLIPSIS)
result = #CDRF_SKIPDEFAULT
EndSelect
EndIf
EndIf
ProcedureReturn Result
EndProcedure
OpenWindow(0, 200, 100, 600, 400, "Demo")
ListIconGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20, "Name", 110 , #PB_ListIcon_FullRowSelect)
AddGadgetColumn(0, 1, "Address", 240)
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")
SetGadgetColor(0, #PB_Gadget_BackColor, $303030)
SetGadgetColor(0, #PB_Gadget_FrontColor, $909090)
hHeader = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
DefaultListIconCallback = SetWindowLongPtr_(GadgetID(0), #GWL_WNDPROC, @CustomListIconCallback())
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow