Page 1 of 1
Change color frame and scrollbar of ListIconGadget[Resolved]
Posted: Wed Sep 24, 2008 12:12 pm
by Kwai chang caine
Hello at all
Is it possible to change the color of a ListIconGadget ???
I want to say the frame and the ScrollingBar and the font ???
Thanks for your help
Good day
Posted: Wed Sep 24, 2008 2:48 pm
by Fluid Byte
Frame? Yes! Font? Yes! Scrollbar? Not at all!
Posted: Wed Sep 24, 2008 3:17 pm
by Kwai chang caine
Thanks Fluid byte for your interest
Obviously you know my second question
Have you ever see a link or a code to do this ?? :roll:
Posted: Wed Sep 24, 2008 4:49 pm
by Fluid Byte
Code: Select all
OpenWindow(0,0,0,340,380,"void",#PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ContainerGadget(0,0,0,0,0)
ListIconGadget(1,0,0,0,0,"Name",290)
CloseGadgetList()
SetWindowLong_(GadgetID(0),#GWL_STYLE,GetWindowLong_(GadgetID(0),#GWL_STYLE) | #WS_CLIPCHILDREN)
SetWindowLong_(GadgetID(1),#GWL_EXSTYLE,0)
SetGadgetColor(0,#PB_Gadget_BackColor,#Red)
For i=1 To 80 : AddGadgetItem(1,-1,"List-View Item #" + Str(i)) : Next
For i=0 To CountGadgetItems(1)
SetGadgetItemColor(1,i,#PB_Gadget_FrontColor,Random($FFFFFF))
Next
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_SizeWindow
CXEDGE = GetSystemMetrics_(#SM_CXEDGE)
ResizeGadget(0,10,10,WindowWidth(0)-20,WindowHeight(0)-20)
ResizeGadget(1,CXEDGE,CXEDGE,GadgetWidth(0)-CXEDGE*2,GadgetHeight(0)-CXEDGE*2)
EndIf
Until EventID = #PB_Event_CloseWindow
The scrollbar is also customizable but you have to make your own then.
Posted: Thu Sep 25, 2008 9:48 am
by Kwai chang caine
Thanks a lot FLUID BYTE
If i add your code, with one of the code of SPARKIE and SROD, i have almost all
http://www.purebasic.fr/english/viewtop ... red+header
http://www.purebasic.fr/english/viewtop ... red+header
http://www.purebasic.fr/english/viewtop ... lor+colour
http://www.purebasic.fr/english/viewtop ... red+header
http://www.purebasic.fr/english/viewtop ... lor+colour
The frame, the header, only scrolbar failled.
I search how i can create my scrolbar for color it to the color desired :roll:
Thanks again of your kindness
I wish you a very good day
Posted: Thu Sep 25, 2008 4:32 pm
by Shardik
Fluid Byte wrote:Scrollbar? Not at all!
With a combination of dirty tricks it's possible to change the background color of the scrollbar. I even worked out 2 solutions

but only post the shorter variant which hides the default vertical scrollbar of the ListIconGadget and instead displays a ScrollBarGadget syncronized with the content of the ListIconGadget. The other more complex variant involves the use of the FlatSB-API which unfortunately isn't supported anymore from Microsoft since ComCtl32.dll version 6 and higher.
Code: Select all
Procedure WindowCallback(WindowHandle, Msg, WParam, LParam)
Shared BackgroundBrush
Shared NumRowsTotal
Shared RowHeight
Static LastIndex
Protected CurrentIndex
Protected Result = #PB_ProcessPureBasicEvents
Select Msg
Case #WM_PAINT
ShowScrollBar_(GadgetID(0), #SB_VERT, #False)
Case #WM_CTLCOLORSCROLLBAR
Result = BackgroundBrush
Case #WM_VSCROLL
CurrentIndex = GetGadgetState(1)
SendMessage_(GadgetID(0), #LVM_SCROLL, 0, (CurrentIndex - LastIndex) * RowHeight)
LastIndex = CurrentIndex
EndSelect
ProcedureReturn Result
EndProcedure
If OpenWindow(0, 100, 100, 270, 105, "Colored scrollbar background", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
ScrollBarWidth = GetSystemMetrics_(#SM_CXVSCROLL)
ListIconGadget(0, 5, 5, WindowWidth(0) - ScrollBarWidth - 10, WindowHeight(0) - 10, "Column 1", 100)
AddGadgetColumn(0, 1, "Column 2", 100)
For i = 1 To 20
AddGadgetItem(0, -1, "Line " + Str(i) + ", Column 1" + #LF$ + "Line " + Str(i) + ", Column 2")
Next i
NumRowsTotal = CountGadgetItems(0)
NumVisibleRows = SendMessage_(GadgetID(0), #LVM_GETCOUNTPERPAGE, 0, 0)
RowHeight = SendMessage_(GadgetID(0), #LVM_GETITEMSPACING, #True, 0) >> 16
ScrollBarGadget(1, WindowWidth(0) - ScrollBarWidth - 5, 5, ScrollBarWidth, WindowHeight(0) - 10, 0, NumRowsTotal, NumVisibleRows, #PB_ScrollBar_Vertical)
BackgroundBrush = CreateSolidBrush_(#Green)
SetWindowCallback(@WindowCallback())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
DeleteObject_(BackgroundBrush)
EndIf
EndIf
Posted: Fri Sep 26, 2008 5:52 am
by Kwai chang caine
Thanks, thanks, thanks SHARDIK
With you all, i move with the complet solution
Now, just the color of the button and the two arrow is failled
Thanks again at all

Posted: Fri Sep 26, 2008 7:21 am
by akj
In Fluid Byte's first program above are the lines:
Code: Select all
SetWindowLong_(GadgetID(0),#GWL_STYLE,GetWindowLong_(GadgetID(0),#GWL_STYLE) | #WS_CLIPCHILDREN)
SetWindowLong_(GadgetID(1),#GWL_EXSTYLE,0)
I know these lines are manipulating gadget/window style attributes, but in the context of his program what does adding #WS_CLIPCHILDREN for the container gadget achieve?
Which are the pertinent attributes being renoved fron the list icon gadget and what does their removal achieve?
I would be pleased if someone could shed some light on this.
Posted: Fri Sep 26, 2008 3:16 pm
by Fluid Byte
I have put the ListIconGadget into a container to create the border. So when you resize the container the ListIconGadget will flicker. But when you set the #WS_CLIPCHILDREN style to the container it will still update it's client area but excludes all it's child windows.
Also I set the extended style of the ListIconGadget to NULL wich will remove the standard border wich is normally set with #WS_EX_CLIENTEDGE.