ScrollArea scrollbar size

Just starting out? Need help? Post your questions and find answers here.
User avatar
le_magn
Enthusiast
Enthusiast
Posts: 289
Joined: Wed Aug 24, 2005 12:11 pm
Location: Italia

ScrollArea scrollbar size

Post 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...
Last edited by le_magn on Mon Nov 25, 2024 12:44 am, edited 1 time in total.
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: ScrollArea scrollbar size

Post 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
Egypt my love
User avatar
le_magn
Enthusiast
Enthusiast
Posts: 289
Joined: Wed Aug 24, 2005 12:11 pm
Location: Italia

Re: ScrollArea scrollbar size

Post 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
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: ScrollArea scrollbar size

Post by RASHAD »

Egypt my love
Post Reply