Page 1 of 1

Owner-drawn scrollbars inside ListIconGadget possible?

Posted: Sun Jun 15, 2014 3:05 pm
by chi
Hi all,

I'm actually working on a themed UI for PB and after adding the easier parts (Buttons, Checkboxes, etc.) I'm kinda stuck with gadgets like the ListIconGadget... Because of the scrollbars that may appear.
Though I found some nice code to color the background bar of the scrollbars I'm not quite sure if it's possible to completely owner-draw such controls?! Could anyone shed some light on it? ;)

Thanks, chi

Image

Re: Owner-drawn scrollbars inside ListIconGadget possible?

Posted: Sun Jun 15, 2014 7:53 pm
by RASHAD
Hi
Search the forum for Fluid Byte Fantastic Custom Scroll Bar
Next is a small example you can adapt it and complete it

Code: Select all

LoadFont(0,"Marlett",10)

CreateImage(0,18,30)
StartDrawing(ImageOutput(0))
		Box(0,0,18,30,$C4C4C4)
		Box(2,8,14,2,$E1E1E1)
		Box(2,12,14,2,$E1E1E1)
		Box(2,16,14,2,$E1E1E1)
StopDrawing()

If OpenWindow(0, 0, 0, 320, 200, "TrackBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    
  ContainerGadget(0,290,10,20,180,#PB_Container_Single)
  ButtonGadget(1,0,0,18,15,Chr($74),#WS_BORDER)
  SetGadgetFont(1,FontID(0))
  ButtonGadget(2,0,163,18,15,Chr($75),#WS_BORDER)
  SetGadgetFont(2,FontID(0))
  ImageGadget(3,0,15,10,10,ImageID(0))
  CloseGadgetList() 
  SetGadgetColor(0,#PB_Gadget_BackColor,#Gray)
  
  ContainerGadget(10,10,10,280,180,#PB_Container_Flat)
    ListIconGadget(20,-1,-1,310,184,"Column #0",80,#PB_ListIcon_CheckBoxes|#PB_ListIcon_FullRowSelect| #LVS_NOCOLUMNHEADER)
  CloseGadgetList()
  
  For x=1 To 2
     AddGadgetColumn(20,x,"Column #"+Str(x),80)
  Next
  
  For r = 0 To 68
      AddGadgetItem(20,-1,"Item #" +Str(r) +Chr(10)+"Item #1"+Chr(10)+"Item #2")
  Next
  
  SetGadgetColor(20,#PB_Gadget_BackColor,#Gray)
  SetGadgetColor(20,#PB_Gadget_FrontColor,#White) 
  RowHeight = SendMessage_(GadgetID(20), #LVM_GETITEMSPACING, #True, 0) >> 16
  
  SetWindowColor(0,#Gray)
Repeat
    Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
        Quit = 1 
        
      Case #PB_Event_Gadget
            Select EventGadget()
                  Case 1
                        If GadgetY(3) > 15
                            SendMessage_(GadgetID(20), #LVM_SCROLL, 0, - RowHeight)
                            ResizeGadget(3,#PB_Ignore,GadgetY(3)-2,#PB_Ignore,#PB_Ignore)
                        EndIf

                  Case 2
                        If GadgetY(3) < 132
                            SendMessage_(GadgetID(20), #LVM_SCROLL, 0, RowHeight)
                            ResizeGadget(3,#PB_Ignore,GadgetY(3)+2,#PB_Ignore,#PB_Ignore)
                        EndIf
                  Case 3
            EndSelect
            
  EndSelect    
 Until Quit = 1
EndIf

Re: Owner-drawn scrollbars inside ListIconGadget possible?

Posted: Mon Jun 16, 2014 1:29 pm
by chi
Thanks for your example, RASHAD!

So it seems that the only way to color the scrollbars is to hide the original ones and draw them in a separate gadget... DOH! (http://stackoverflow.com/questions/4397 ... n-winforms). TY MS for making it so hard!!!
I already tried Fluid Byte's Scrollbars but unfortunately they don't support borderless windows (which are also needed for my project). Guess I need to start from scratch ;(


cheers, chi