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.