1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
StatusBar1: TStatusBar;
swView1: TCheckBox;
swInitSize: TCheckBox;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
procedure Button1Click(Sender: TObject);
procedure swView1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R unit1.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
btn: TToolButton;
//i, rows: integer;
//w: integer;
r: TRect;
begin
btn := TToolButton.Create(ToolBar1);
btn.Name:='TestButton'+IntToStr(ToolBar1.ComponentCount);
btn.Parent := ToolBar1;
btn.Style := tbsCheck;
btn.AutoSize := True;
if swInitSize.Checked then
btn.Width := 100;
btn.Caption := 'button ' + IntToStr(btn.Index);
btn.Grouped := True;
{
w := ToolBar1.BorderWidth;
rows := 1;
for i := 0 to ToolBar1.ButtonCount - 1 do begin
btn := ToolBar1.Buttons[i];
inc(w, btn.Width);
if w > ToolBar1.Width then begin
inc(rows);
w := btn.Width + ToolBar1.BorderWidth;
end;
end;
//rows := (w div ToolBar1.Width) + 1;
ToolBar1.Height := btn.Height * rows;
}
btn := ToolBar1.Buttons[ToolBar1.ButtonCount-1];
r := btn.BoundsRect;
StatusBar1.SimpleText := 'Bottom: ' + IntToStr(r.Bottom);
//ToolBar1.Height := r.Bottom;
end;
procedure TForm1.swView1Click(Sender: TObject);
begin
ToolButton1.Visible := swView1.Checked;
end;
end.
|