how use ListView_SetTextBkColor in pb ?

Everything else that doesn't fall into one of the other PB categories.
User avatar
bingo
Enthusiast
Enthusiast
Posts: 210
Joined: Fri Apr 02, 2004 12:21 pm
Location: germany/thueringen
Contact:

how use ListView_SetTextBkColor in pb ?

Post by bingo »

["1:0>1"]
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

For ListIconGadgets, use the #LVM_SETTEXTBKCOLOR message.

Code: Select all

#CLR_NONE = -1
If OpenWindow(0, 10, 10, 500, 300, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget, "ListIconGadget BKColor") And CreateGadgetList(WindowID())
  ListIconGadget(0, 10, 10, 480, 280, "Column 0", 238)
  AddGadgetColumn(0, 1, "Column 1", 238)
  AddGadgetItem(0, -1, "C0-R0"+Chr(10)+"C1-R0", 0)
  AddGadgetItem(0, -1, "C0-R1"+Chr(10)+"C1-R1", 0)
  AddGadgetItem(0, -1, "C0-R2"+Chr(10)+"C1-R2", 0)
  AddGadgetItem(0, -1, "C0-R3"+Chr(10)+"C1-R3", 0)
  AddGadgetItem(0, -1, "C0-R4"+Chr(10)+"C1-R4", 0)
  SendMessage_(GadgetID(0), #LVM_SETBKCOLOR, 0, RGB(255, 255, 200))
  SendMessage_(GadgetID(0), #LVM_SETTEXTCOLOR, 0, RGB(0, 128, 255))
  SendMessage_(GadgetID(0), #LVM_SETTEXTBKCOLOR, 0, #CLR_NONE)
  Repeat
    event = WaitWindowEvent()
  Until event = #PB_EventCloseWindow
EndIf
End
For ListViewGadgets, use a callback and catch the #WM_CTLCOLORLISTBOX message.

Code: Select all

; --> Create solid brush1
hBrush1 = CreateSolidBrush_(RGB(255, 255, 200))

; --> Create solid brush2
hBrush2 = CreateSolidBrush_(RGB(100, 0, 200))

Global hBrush1, hBrush2

Procedure.l myWindowCallback(hwnd, msg, wparam, lparam)
  result = #PB_ProcessPureBasicEvents
  Select msg
    Case #WM_CTLCOLORLISTBOX 
      Select lparam
        Case GadgetID(0)
          SetBkMode_(wparam, #TRANSPARENT)
          SetTextColor_(wparam, RGB(0, 128, 255))
          result = hBrush1
        Case GadgetID(1)
          SetBkMode_(wparam, #TRANSPARENT)
          SetTextColor_(wparam, RGB(0, 0, 0))
          result = hBrush2
      EndSelect
  EndSelect
  ProcedureReturn result
EndProcedure

If OpenWindow(0, 10, 10, 500, 300, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget, "ListViewGadget Colors") And CreateGadgetList(WindowID())
  SetWindowCallback(@myWindowCallback())
  ListViewGadget(0, 10, 10, 230, 280)
  For row = 0 To 4
    AddGadgetItem(0, row, "Row " + Str(row))
  Next
  ListViewGadget(1, 260, 10, 230, 280)
  For row = 0 To 4
    AddGadgetItem(1, row, "Row " + Str(row))
  Next
  Repeat
    event = WaitWindowEvent()
  Until event = #PB_EventCloseWindow
  DeleteObject_(hBrush1)
  DeleteObject_(hBrush2)
EndIf
End
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply