Lazarus

Programming => General => Topic started by: pixelink on May 15, 2019, 02:54:56 pm

Title: Drawing or Changing scroll bar color on SynEdit
Post by: pixelink on May 15, 2019, 02:54:56 pm
I am making an program that uses SynEdit.
The background color is black with colored text

However, the light gray (default) scrollbar color stands out to much, Is there an easy way to color the vert/horizontal scrollbars?? to a "clGray" color?
Title: Re: Drawing or Changing scroll bar color on SynEdit
Post by: Martin_fr on May 15, 2019, 03:36:50 pm
They are drawn by the OS, according to the OS team. There is currently no easy way to replace them.
Title: Re: Drawing or Changing scroll bar color on SynEdit
Post by: pixelink on May 15, 2019, 03:41:41 pm
They are drawn by the OS, according to the OS team. There is currently no easy way to replace them.

rats... Thanks
Title: Re: [DONE] Drawing or Changing scroll bar color on SynEdit
Post by: M.A.R.C. on May 20, 2019, 05:54:52 am
I have the same problem :(
Maybe is possible to set Scrollbars to ssNone and put some kind of self-painted scrollbars...
Title: Re: [DONE] Drawing or Changing scroll bar color on SynEdit
Post by: M.A.R.C. on May 20, 2019, 06:59:08 am
Ok, I was able to make a proof of concept.

Code: Pascal  [Select]
  1. unit MainFormU;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, SynEdit,
  9.   GR32_RangeBars;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     HBar: TGaugeBar;
  17.     VBar: TGaugeBar;
  18.     SynEdit1: TSynEdit;
  19.     procedure HBarChange(Sender: TObject);
  20.     procedure SynEdit1Paint(Sender: TObject; ACanvas: TCanvas);
  21.     procedure VBarChange(Sender: TObject);
  22.   private
  23.  
  24.   public
  25.  
  26.   end;
  27.  
  28. var
  29.   Form1: TForm1;
  30.  
  31. implementation
  32.  
  33. { TForm1 }
  34.  
  35. procedure TForm1.HBarChange(Sender: TObject);
  36. begin
  37.   SynEdit1.LeftChar:=HBar.Position+1;
  38. end;
  39.  
  40. procedure TForm1.SynEdit1Paint(Sender: TObject; ACanvas: TCanvas);
  41. begin
  42.   VBar.Max:=SynEdit1.Lines.Count-SynEdit1.LinesInWindow;
  43.   VBar.Position:=SynEdit1.TopLine-1;
  44.   HBar.Max:=SynEdit1.CharsInWindow-SynEdit1.LeftChar;
  45.   HBar.Position:=SynEdit1.LeftChar-1;
  46. end;
  47.  
  48. procedure TForm1.VBarChange(Sender: TObject);
  49. begin
  50.   SynEdit1.TopLine:=VBar.Position+1;
  51. end;
  52.  
  53. initialization
  54.   {$I mainformu.lrs}
  55.  
  56. end.
  57.  
Title: Re: [DONE] Drawing or Changing scroll bar color on SynEdit
Post by: pixelink on May 20, 2019, 11:58:33 am
Interesting... but I don't see where the color gray is drawn in your code.

Can you elaborate?
Title: Re: [DONE] Drawing or Changing scroll bar color on SynEdit
Post by: M.A.R.C. on May 20, 2019, 04:23:25 pm
Interesting... but I don't see where the color gray is drawn in your code.

Can you elaborate?

I'm using the Graphics32 library and the TGaugebar component to customizing the scrollbar.

regards
Title: Re: Drawing or Changing scroll bar color on SynEdit
Post by: Alextp on May 22, 2019, 11:49:26 pm
Also can use ATFlatControls with ATScrollbar, you can change color of such bars via ATFlatTheme global record.
Title: Re: Drawing or Changing scroll bar color on SynEdit
Post by: Martin_fr on May 29, 2019, 09:37:24 am
Only works without folding:
https://forum.lazarus.freepascal.org/index.php/topic,44690.msg314456.html#msg314456