background color listviewgadget

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.


The following code does not work for listview gadget:
using win98 se.

Any suggestions?

Code: Select all

 ListIconGadget = ListIconGadget(0, 0, 0, LVWidth, WindowHeight()-30, "This", LVWidth/4-1)
  AddGadgetColumn(0, 1, "is", LVWidth/4-1)
  AddGadgetColumn(0, 2, "a", LVWidth/4-1)
  AddGadgetColumn(0, 3, "test", LVWidth/4-1)

  SendMessage_(ListIconGadget, #LVM_SETBKCOLOR, 0, RGB(128, 128, 128)) ; change blank cells background color
  SendMessage_(ListIconGadget, #LVM_SETTEXTBKCOLOR, 0, RGB(216, 64, 216)) ; change cells background color
  SendMessage_(ListIconGadget, #LVM_SETTEXTCOLOR, 0, RGB(0, 32, 128)) ; change text color

  AddListIconGadgetItem(0, 0, "Column 1"+Chr(10)+"Column 2"+Chr(10)+"Column 3"+Chr(10)+"Column 4", 0)

Using Windows 98 SE
Registered PB version : 3.30 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

Hello cor,

I have the following part of code in an app :

SendMessage_(ListIconGadget, #LVM_SETTEXTBKCOLOR, 0, #Background_ListView)
SendMessage_(ListIconGadget, #LVM_SETTEXTCOLOR, 0, #Foreground_ListView)
SendMessage_(ListIconGadget, #LVM_SETBKCOLOR, 0, #Background_ListView)

where constants are equivalent to RGB(x, y, z), and it works fine here.

Are you sure the problem is not outside the part of code you sent (like some stuff in a callback) ?

Rgrds

Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

You will have URLPopularity application on Paul's ressource site(apps section) soon. I've just posted it now.

It contains an example of a list view with this coloring stuff.

KRgrds

Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

Francois,

I'am using a listviewgadget, not an listicongadget. (maybe that is the problem)

Using Windows 98 SE
Registered PB version : 3.30 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

Its using a callback, but its very easy to understand:

Code: Select all

;- Set Listview Colors
ListViewTextColor = RGB(255,255,000)
ListViewBackColor = RGB(000,000,000)

;- Init for ListView Coloring
ListViewBackBrush = CreateSolidBrush_(ListViewBackColor)

;- Open Window with Gadget
hWnd = OpenWindow(0,100,100,400,400,#PB_Window_SystemMenu,"Colored ListView")
       CreateGadgetList(hWnd)
       ;- Font
       hFont = LoadFont(1,"Lucida Console",14)
       SetGadgetFont(hFont)
       ;- ListView Gadget
       ListViewGadget(0,10,10,380,380)

;- add ListView entries
For a = 1 To 1000
    AddGadgetItem(0,-1,"ListView Line "+Str(a))
Next a

;- Window Callback
Procedure myWinCallback(Window, Message, wParam, lParam)
Shared ListViewTextColor, ListViewBackBrush  ;  #PB_EventCloseWindow : Wend

;- Cleanup
DeleteObject_(ListViewBackBrush)
Just read it step by step... everything is logical.

cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

Thanks Danilo,

It works.

ps.
Is there also a way to do it for only 1 specific listviewgadget, not for all?

Using Windows 98 SE
Registered PB version : 3.30 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Post Reply