Page 1 of 1

ScrollArea scrollbar size

Posted: Thu Nov 21, 2024 11:18 pm
by le_magn
Hi all, I'm finalizing a little program, but there is one thing that clashes with the appearance of the GUI. it's the scroll sidebars, too square and too wide, does anyone know if there is any trick to change their style or at least shrink them? thanks...

Re: ScrollArea scrollbar size

Posted: Fri Nov 22, 2024 12:32 am
by RASHAD
Hi
Windows 11 solved this :wink:
Changing the scrollbar width using Windows system internals is not a good idea
Next is a custom snippet
Todo : The Scrollbar and The MouseWheel responding

Code: Select all

Global yNewPos,yCurrentScroll,Brush


Procedure WndProc(hwnd, uMsg, wParam, lParam)
  
  If IsGadget(0)
    yCurrentScroll = GetGadgetAttribute(0,#PB_ScrollArea_Y) 
  EndIf
  
  Result = #PB_ProcessPureBasicEvents
  
  Select uMsg
      
    Case #WM_VSCROLL
      
      Select wParam & $FFFF
          
        Case #SB_PAGEUP 
          yNewPos = yCurrentScroll - 1
          
        Case #SB_PAGEDOWN
          yNewPos = yCurrentScroll + 1
          
        Case #SB_LINEUP 
          yNewPos = yCurrentScroll - 1
          
        Case #SB_LINEDOWN 
          yNewPos = yCurrentScroll + 1
          
        Case #SB_THUMBPOSITION 
          yNewPos = wParam >> 16 & $FFFF
          
      EndSelect
      
      SetGadgetAttribute(0,#PB_ScrollArea_Y,yNewPos)
      SetGadgetState(5,yNewPos)
      
      
    Case #WM_CTLCOLORSCROLLBAR
      Result = Brush
      
  EndSelect
  
  ProcedureReturn Result
EndProcedure

ScrollBarHeight = 10 
ExamineDesktops() 

If OpenWindow(0, 0, 0, 610, 400, "Custom ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ScrollAreaGadget(0, 10, 10, 580,380, DesktopWidth(0),DesktopHeight(0), 25,#PB_ScrollArea_Single)
  ShowScrollBar_(GadgetID(0), #SB_BOTH, 0)
  SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) | #WS_CLIPSIBLINGS)
  SetWindowPos_(GadgetID(0), #HWND_BOTTOM	, -1, -1, -1, -1, #SWP_NOSIZE | #SWP_NOMOVE)
  ButtonGadget  (1, 10, 150, 90, 90,"Button 1")
  ButtonGadget  (2, 110, 150, 90, 90,"Button 2")
  ButtonGadget  (3, 210, 150, 90, 90,"Button 3")     
  CloseGadgetList()
  
  ScrollBarGadget(5, 590,10, 10,GadgetHeight(0), 0,400,10, #PB_ScrollBar_Vertical)
  SetWindowLongPtr_(GadgetID(5), #GWL_STYLE, GetWindowLongPtr_(GadgetID(5), #GWL_STYLE) | #WS_CLIPSIBLINGS)
  SetWindowPos_(GadgetID(5), #HWND_TOP, -1, -1, -1, -1, #SWP_NOSIZE | #SWP_NOMOVE)
  Brush = CreateSolidBrush_($BEBEBF)
  SetWindowCallback(@WndProc())
  
  
  Repeat
    Select WaitWindowEvent()
      Case  #PB_Event_CloseWindow
        End
      Case  #PB_Event_Gadget
        Select EventGadget()
          Case 1
            MessageRequester("Info","Button 1 was pressed!",#PB_MessageRequester_Ok)
          Case 2
            MessageRequester("Info","Button 2 was pressed!",#PB_MessageRequester_Ok)
          Case 3
            MessageRequester("Info","Button 3 was pressed!",#PB_MessageRequester_Ok)
        EndSelect
    EndSelect
  ForEver
  DeleteObject_(Brush)
EndIf

Re: ScrollArea scrollbar size

Posted: Fri Nov 22, 2024 1:12 am
by le_magn
RASHAD wrote: Fri Nov 22, 2024 12:32 am Hi
Windows 11 solved this :wink:
Changing the scrollbar width using Windows system internals is not a good idea
Next is a custom snippet
Todo : The Scrollbar and The MouseWheel responding
Rashad I tried your code and it will be useful, thank you very much

Re: ScrollArea scrollbar size

Posted: Fri Nov 22, 2024 8:29 am
by RASHAD