Marco Cantù 1998, Mastering Delphi 4

Project: CTRLBAR.DPR


Project Structure


CTRLBAR.DPR

program CtrlBar;

uses
  Forms,
  CtrlForm in 'CtrlForm.pas' {Form1};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

CTRLFORM.PAS

unit CtrlForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Buttons, StdCtrls, ExtCtrls, Menus, ComCtrls, ToolWin, ImgList;

type
  TForm1 = class(TForm)
    ControlBar: TControlBar;
    ComboFont: TComboBox;
    Label1: TLabel;
    ImageList1: TImageList;
    ToolFontStyle: TToolBar;
    tbBold: TToolButton;
    tbitalic: TToolButton;
    tbUnderline: TToolButton;
    ToolAlign: TToolBar;
    tbNote: TToolButton;
    ToolButton9: TToolButton;
    tbLeft: TToolButton;
    tbCenter: TToolButton;
    tbRight: TToolButton;
    procedure tbLeftClick(Sender: TObject);
    procedure tbCenterClick(Sender: TObject);
    procedure tbRightClick(Sender: TObject);
    procedure tbNoteClick(Sender: TObject);
    procedure tbBoldClick(Sender: TObject);
    procedure tbitalicClick(Sender: TObject);
    procedure tbUnderlineClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ComboFontChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.tbLeftClick(Sender: TObject);
begin
  Label1.Alignment := taLeftJustify;
end;

procedure TForm1.tbCenterClick(Sender: TObject);
begin
  Label1.Alignment := taCenter;
end;

procedure TForm1.tbRightClick(Sender: TObject);
begin
  Label1.Alignment := taRightJustify;
end;

procedure TForm1.tbNoteClick(Sender: TObject);
begin
  Beep;
end;

procedure TForm1.tbBoldClick(Sender: TObject);
begin
  with Label1.Font do
    if fsBold in Style then
      Style := Style - [fsBold]
    else
      Style := Style + [fsBold];
end;

procedure TForm1.tbitalicClick(Sender: TObject);
begin
  with Label1.Font do
    if fsItalic in Style then
      Style := Style - [fsItalic]
    else
      Style := Style + [fsItalic];
end;

procedure TForm1.tbUnderlineClick(Sender: TObject);
begin
  with Label1.Font do
    if fsUnderline in Style then
      Style := Style - [fsUnderline]
    else
      Style := Style + [fsUnderline];
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ComboFont.Items := Screen.Fonts;
  ComboFont.ItemIndex :=
    ComboFont.Items.IndexOf (Label1.Font.Name);
end;

procedure TForm1.ComboFontChange(Sender: TObject);
begin
  Label1.Font.Name := ComboFont.Text;
end;

end.

CTRLFORM.DFM

object Form1: TForm1
  Left = 193
  Top = 107
  Width = 671
  Height = 392
  Caption = 'CtrlBar (Control Bar Demo)'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 0
    Top = 30
    Width = 663
    Height = 335
    Align = alClient
    Caption =
       'A caption with some sample text to show the effect of the speed ' +
      'buttons of the toolbar. You can replace it with something more u' +
      'seful.'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -19
    Font.Name = 'Arial'
    Font.Style = []
    ParentFont = False
    WordWrap = True
  end
  object ControlBar: TControlBar
    Left = 0
    Top = 0
    Width = 663
    Height = 30
    Align = alTop
    AutoDrag = False
    AutoSize = True
    DockSite = False
    DragKind = dkDock
    RowSize = 25
    RowSnap = False
    TabOrder = 0
    object ComboFont: TComboBox
      Left = 214
      Top = 2
      Width = 167
      Height = 21
      Style = csDropDownList
      ItemHeight = 13
      TabOrder = 0
      OnChange = ComboFontChange
    end
    object ToolFontStyle: TToolBar
      Left = 129
      Top = 2
      Width = 72
      Height = 22
      AutoSize = True
      EdgeBorders = []
      EdgeInner = esNone
      EdgeOuter = esNone
      Flat = True
      Images = ImageList1
      TabOrder = 1
      object tbBold: TToolButton
        Left = 0
        Top = 0
        Caption = 'tbBold'
        ImageIndex = 4
        Style = tbsCheck
        OnClick = tbBoldClick
      end
      object tbitalic: TToolButton
        Left = 23
        Top = 0
        Caption = 'tbitalic'
        ImageIndex = 5
        Style = tbsCheck
        OnClick = tbitalicClick
      end
      object tbUnderline: TToolButton
        Left = 46
        Top = 0
        Caption = 'tbUnderline'
        ImageIndex = 6
        Style = tbsCheck
        OnClick = tbUnderlineClick
      end
    end
    object ToolAlign: TToolBar
      Left = 11
      Top = 2
      Width = 105
      Height = 22
      AutoSize = True
      EdgeBorders = []
      EdgeInner = esNone
      EdgeOuter = esNone
      Flat = True
      Images = ImageList1
      TabOrder = 2
      object tbNote: TToolButton
        Left = 0
        Top = 0
        Caption = 'ToolButton3'
        ImageIndex = 0
        OnClick = tbNoteClick
      end
      object ToolButton9: TToolButton
        Left = 23
        Top = 0
        Width = 8
        Caption = 'ToolButton6'
        ImageIndex = 3
        Style = tbsSeparator
      end
      object tbLeft: TToolButton
        Left = 31
        Top = 0
        Caption = 'ToolButton4'
        Grouped = True
        ImageIndex = 1
        OnClick = tbLeftClick
      end
      object tbCenter: TToolButton
        Left = 54
        Top = 0
        Caption = 'ToolButton5'
        Grouped = True
        ImageIndex = 2
        OnClick = tbCenterClick
      end
      object tbRight: TToolButton
        Left = 77
        Top = 0
        Caption = 'ToolButton7'
        Grouped = True
        ImageIndex = 3
        OnClick = tbRightClick
      end
    end
  end
  object ImageList1: TImageList
    Left = 32
    Top = 88
    Bitmap = {
      360C000007000000424D360C0000000000003604000028000000400000002000
      0000010008000000000000080000000000000000000000010000000000000000
      0000000080000080000000808000800000008000800080800000C0C0C000C0DC
      C000F0CAA6000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000000000000000F0FBFF00A4A0A0008080
      80000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000007070707070707070707070707F8FF070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000070707070707070707070707070707070000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000000000000000000000000000424D
      3E010000000000003E0000002800000040000000200000000100010000000000
      000100000000000000000000020000000000000000000000FFFFFF00FFFFFFFF
      FFFF0000FFFFFFFFFFFFF800E01FF03FF00F0000E00FFCFFF00FF800F3CFFCFF
      FFFFF800F3CFFCFFFC4F00F8F38FFE7FF80F0000F01FFE7FF91FF800F00FFE7F
      F99F0000F3CFFF3FF99FF803F3CFFF3FF99FF800E00FFC0FF11FF803E01FFFFF
      FFFF0000FFFFFFFFFFFF0003FFFFFFFFFFFF0000FFFFFFFFFFFF0100CFFF8001
      80018001873FBFFDBFFDBFFD821FA03DB81DBC05C20FBFFDBFFDBFFDFB0FA3FD
      BC3DBFC5FBEFBFFDBFFDBFFDFBEFA0FDB81DBF05FBEFBFFDBFFDBFFDFBEFA3FD
      BE7DBFC5FBEFBFFDBFFDBFFDF8EFA01DB00DB805FB0FBFFDBFFDBFFDF8EFA07D
      B81DBE05FF0FBFFDBFFDBFFDFFFF800180018001FFFFFFFFFFFFFFFF}
  end
end


Copyright Marco Cantù 1998