Change color frame and scrollbar of ListIconGadget[Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5528
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Change color frame and scrollbar of ListIconGadget[Resolved]

Post 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
Last edited by Kwai chang caine on Thu Sep 25, 2008 9:50 am, edited 1 time in total.
ImageThe happiness is a road...
Not a destination
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Frame? Yes! Font? Yes! Scrollbar? Not at all!
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5528
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Thanks Fluid byte for your interest 8)

Obviously you know my second question :D
Have you ever see a link or a code to do this ?? :roll:
ImageThe happiness is a road...
Not a destination
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post 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.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5528
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Thanks a lot FLUID BYTE 8)

If i add your code, with one of the code of SPARKIE and SROD, i have almost all :D

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 8)
I wish you a very good day
ImageThe happiness is a road...
Not a destination
User avatar
Shardik
Addict
Addict
Posts: 2075
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Post 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 8) 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
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5528
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Thanks, thanks, thanks SHARDIK 8)

With you all, i move with the complet solution 8)
Now, just the color of the button and the two arrow is failled :D

Thanks again at all 8)
ImageThe happiness is a road...
Not a destination
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post 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.
Anthony Jordan
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post 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.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
Post Reply