Recent

Author Topic: Change ScrollBar color  (Read 4233 times)

Edson

  • Hero Member
  • *****
  • Posts: 1328
Change ScrollBar color
« on: October 25, 2017, 10:57:57 pm »
I need to change the Scrollbars color of a ListBox, a TreeView, and a SynEdit component.

Is there some property or event to do this, or what other alternatives exist?
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

jamie

  • Hero Member
  • *****
  • Posts: 7660
Re: Change ScrollBar color
« Reply #1 on: October 26, 2017, 03:01:46 am »
Not easy..
 a scrollbar most of the time is part of the main control. for example the listbox has a scrollbar but it
is automatically create when you create the listbox.

 Windows sets all the needed items for the scrollbar control when it creates the listbox for you.

 You can get at the scrollbar. You need to EnumChildWindows looking for the "SCROLLBAR" control class.
 when you find it, it'll give you a handle to the control.

  With this handle you can alter the colors using API functions but I am not sure how retained they will be

 SetBkColor should do it..

  You need to experiment a little..
  Look on the net for getting the handle to a scrollbar control in a listbox and the other controls will work the
same way.
 
 P.S.
   I also use this method to get the Listbox handle of a Combobox to make sure it works back to Win2k..
  Starting some where around vista MS gave a message to obtain it, but nothing earlier.

 Happy hunting


The only true wisdom is knowing you know nothing

RAW

  • Hero Member
  • *****
  • Posts: 871
Re: Change ScrollBar color
« Reply #2 on: October 26, 2017, 03:08:21 am »
I guess the easiest crossplatform way would be to create your own scrollbar and disable the scrollbars of the other controls, but I have no experience with this...  :)

jamie

  • Hero Member
  • *****
  • Posts: 7660
Re: Change ScrollBar color
« Reply #3 on: October 26, 2017, 04:25:47 am »
Memory is now coming back, scrollbar handles on some Windows controls are not accessible which
is when its a good time to make your own control and use a stand alone scrollbar control.
The only true wisdom is knowing you know nothing

PatBayford

  • Full Member
  • ***
  • Posts: 125
Re: Change ScrollBar color
« Reply #4 on: October 26, 2017, 06:53:29 am »
I strongly suspect that scroll bars are very low level, and hence managed by the OS APIs. I'm not at all sure that any changes made will survive a re-draw! I am, as usual, prepared to be proven wrong!!
Lazarus 1.8.0 FPC 3.0.2 SVN 56594 Windows 10 64bit (i386-win32-win32/win64)

 

TinyPortal © 2005-2018