[SOLVED ]Vertical menu in Lazarus lazarus / 31-LCL ---------------------------------------------------------------------- Wargan · 2017-07-13 10:02 Hello! How can I create a vertical menu like this? (see attachment) Please do not advise me to use Eye Candy Controls. The TECImageMenu component is completely unsuitable for customization in another design (I use a dark theme for my application) ---------------------------------------------------------------------- Ñuño_Martínez · 2017-07-13 11:29 You may use a list of buttons, or a TListBox with appropiate style and events. ---------------------------------------------------------------------- Handoko · 2017-07-13 11:59 Both list of buttons and TListBox failed on my test on Linux. Buttons cannot have custom background color, TListBox.Color can be customized but will back to default if it has items. ---edit--- Buttons can have custom background color, but cannot omit border. ---------------------------------------------------------------------- Handoko · 2017-07-13 13:56 Without writing a new component from scratch, the best thing I can do is using some TPanels + a TScrollBox. The result is not perfect, but at least it works on my Linux tests. You can download my test.zip to try. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Buttons, StdCtrls,  ExtCtrls; type   { TForm1 }   TForm1 = class(TForm)    btnStart: TButton;    Panel1: TPanel;    Panel2: TPanel;    Panel3: TPanel;    ScrollBox1: TScrollBox;    procedure btnStartClick(Sender: TObject);    procedure Panel1Click(Sender: TObject);    procedure Panel2Click(Sender: TObject);    procedure Panel3Click(Sender: TObject);  private    procedure ItemKeyPress(Sender: TObject; var Key: char);    procedure ItemMouseEnter(Sender: TObject);    procedure ItemMouseLeave(Sender: TObject);    procedure ItemTabEnter(Sender: TObject);    procedure ItemTabLeave(Sender: TObject);  public    { public declarations }  end; var  Form1: TForm1; implementation type  HackPanel = TWinControl; {$R *.lfm} { TForm1 } procedure TForm1.btnStartClick(Sender: TObject);begin   btnStart.Enabled    := False;   ScrollBox1.Enabled  := True;  ScrollBox1.Color    := RGBToColor(40, 40, 40);   Panel3.Align        := alTop;  Panel3.Alignment    := taLeftJustify;  Panel3.BevelOuter   := bvNone;  Panel3.Caption      := '     About';  Panel3.Font.Color   := clWhite;  Panel3.Font.Style   := [fsBold];  Panel3.TabStop      := True;  Panel3.Top          := 0;  Panel3.OnMouseEnter := @ItemMouseEnter;  Panel3.OnMouseLeave := @ItemMouseLeave;  Panel3.OnEnter      := @ItemTabEnter;  Panel3.OnExit       := @ItemTabLeave;  (Panel3 as HackPanel).OnKeyPress := @ItemKeyPress;   Panel2.Align        := alTop;  Panel2.Alignment    := taLeftJustify;  Panel2.BevelOuter   := bvNone;  Panel2.Caption      := '     Products';  Panel2.Font.Color   := clWhite;  Panel2.Font.Style   := [fsBold];  Panel2.TabStop      := True;  Panel2.Top          := 0;  Panel2.OnMouseEnter := @ItemMouseEnter;  Panel2.OnMouseLeave := @ItemMouseLeave;  Panel2.OnEnter      := @ItemTabEnter;  Panel2.OnExit       := @ItemTabLeave;  (Panel2 as HackPanel).OnKeyPress := @ItemKeyPress;   Panel1.Align        := alTop;  Panel1.Alignment    := taLeftJustify;  Panel1.BevelOuter   := bvNone;  Panel1.Caption      := '     Home';  Panel1.Font.Color   := clWhite;  Panel1.Font.Style   := [fsBold];  Panel1.TabStop      := True;  Panel1.Top          := 0;  Panel1.OnMouseEnter := @ItemMouseEnter;  Panel1.OnMouseLeave := @ItemMouseLeave;  Panel1.OnEnter      := @ItemTabEnter;  Panel1.OnExit       := @ItemTabLeave;  (Panel1 as HackPanel).OnKeyPress := @ItemKeyPress; end; procedure TForm1.Panel1Click(Sender: TObject);begin  Panel1.SetFocus;  Panel1.OnMouseEnter(Panel1);  Panel2.OnMouseLeave(Panel2);  Panel3.OnMouseLeave(Panel3);  ShowMessage('You have clicked "Home"');end; procedure TForm1.Panel2Click(Sender: TObject);begin  Panel2.SetFocus;  Panel2.OnMouseEnter(Panel2);  Panel1.OnMouseLeave(Panel1);  Panel3.OnMouseLeave(Panel3);  ShowMessage('You have clicked "Products"');end; procedure TForm1.Panel3Click(Sender: TObject);begin  Panel3.SetFocus;  Panel3.OnMouseEnter(Panel3);  Panel2.OnMouseLeave(Panel2);  Panel1.OnMouseLeave(Panel1);  ShowMessage('You have clicked "About"');end; procedure TForm1.ItemKeyPress(Sender: TObject; var Key: char);begin  if not(Sender is TPanel) then Exit;  if (Key = #13) then (Sender as TPanel).OnClick(Sender);end; procedure TForm1.ItemMouseEnter(Sender: TObject);begin  if not(Sender is TPanel) then Exit;  (Sender as TPanel).Color := RGBToColor(40, 160, 180);end; procedure TForm1.ItemMouseLeave(Sender: TObject);begin  if not(Sender is TPanel) then Exit;  (Sender as TPanel).ParentColor := True;end; procedure TForm1.ItemTabEnter(Sender: TObject);begin  if not(Sender is TPanel) then Exit;  with (Sender as TPanel) do  begin    Caption := '>' + RightStr(Caption, Length(Caption)-2);  end;end; procedure TForm1.ItemTabLeave(Sender: TObject);begin  if not(Sender is TPanel) then Exit;  with (Sender as TPanel) do  begin    Caption := '  ' + RightStr(Caption, Length(Caption)-1);  end;end; end. ---------------------------------------------------------------------- ps · 2017-07-13 15:54 Quote from: Handoko on July 13, 2017, 03:56:10 pmWithout writing a new component from scratch, the best thing I can do is using some TPanels + a TScrollBox. This is working only on Windows/Linux.  Under MacOS scrollbox (and all scollbox based components) is broken for years (even in IDE)  https://mantis.freepascal.org/view.php?id=27449 ---------------------------------------------------------------------- Handoko · 2017-07-13 15:57 I haven't tested, but I think we can achieve the similar result if we change the TScrollBox -> TPanel. ---------------------------------------------------------------------- taazz · 2017-07-13 17:50 Quote from: ps on July 13, 2017, 05:54:39 pmQuote from: Handoko on July 13, 2017, 03:56:10 pmWithout writing a new component from scratch, the best thing I can do is using some TPanels + a TScrollBox. This is working only on Windows/Linux.  Under MacOS scrollbox (and all scollbox based components) is broken for years (even in IDE)  https://mantis.freepascal.org/view.php?id=27449 erm the bug report says that the scrollbars are always visible not that they do not work. If I find some time later I might create a small scroll box component with custom scrollbar handling for testing.Until then have you tried to use a list box in lbownerdraw style and write your own on drawitem nad on measureitem events and see if that works? ---------------------------------------------------------------------- ps · 2017-07-13 19:01 I'm using listbox because it's working well on all platforms. Only TScrollBox is broken = always visible scrollbars = broken = don't work for me. In some scenarios there is only small visual problem (like in IDE), but in another scenarios it's big problem ---------------------------------------------------------------------- howardpc · 2017-07-13 21:35 You could perhaps adapt the TVerticalMenu class in the attached project to your needs, publish desired properties, put it in a package and install it in the component palette - or just use it as-is. ---------------------------------------------------------------------- Wargan · 2017-07-14 05:43 Many thanks to all! My problem is solved