Marco's Web Center

Menu for Development

Site Menu
Object Pascal Handbook
Delphi Handbooks Collection
Mastering Borland Delphi 2005
(Old) White Papers
(Old)Tools
(Old) Conferences

My Other Sites
Italian Site (www.marcocantu.it)
the delphi search

Spirit of delphi

Advertising
Home My Blog Books Object Pascal Marco

Home: Code Repository: Mastering Delphi 6

Chapter 06 - Project QMenuImg

Project Structure

QMenuImg.dpr
program QMenuImg;

uses
  QForms,
  MenuImgF in 'MenuImgF.pas' {Form1};

{$R *.res}

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

interface

uses
  Qt, SysUtils, Classes, QGraphics, QControls, QForms, QDialogs,
  QStdCtrls, QMenus, QImgList, QTypes;

type
  TForm1 = class(TForm)
    ImageList1: TImageList;
    MainMenu1: TMainMenu;
    File1: TMenuItem;
    New1: TMenuItem;
    Close1: TMenuItem;
    Help1: TMenuItem;
    About1: TMenuItem;
    Memo1: TMemo;
    LargeFont1: TMenuItem;
    procedure New1Click(Sender: TObject);
    procedure Close1Click(Sender: TObject);
    procedure About1Click(Sender: TObject);
    procedure LargeFont1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.xfm}

procedure TForm1.New1Click(Sender: TObject);
begin
  Memo1.Lines.Clear;
end;

procedure TForm1.Close1Click(Sender: TObject);
begin
  Close;
end;

procedure TForm1.About1Click(Sender: TObject);
begin
  ShowMessage ('Menu Images demo'#13 +
    'from "Mastering Delphi" by Marco Cantý');
end;

procedure TForm1.LargeFont1Click(Sender: TObject);
begin
  if Memo1.Font.Size = 8 then
    Memo1.Font.Size := 12
  else
    Memo1.Font.Size := 8;
  // changes the image style near the item
  LargeFont1.Checked := not LargeFont1.Checked;
end;

end.
MenuImgF.xfm
object Form1: TForm1
  Left = 192
  Top = 107
  Width = 356
  Height = 216
  VertScrollBar.Range = 161
  HorzScrollBar.Range = 345
  ActiveControl = Memo1
  Caption = 'Menu Images'
  Color = clButton
  Font.Color = clText
  Font.Height = 11
  Font.Name = 'MS Sans Serif'
  Font.Pitch = fpVariable
  Font.Style = []
  Font.Weight = 40
  Menu = MainMenu1
  ParentFont = False
  PixelsPerInch = 96
  TextHeight = 13
  TextWidth = 6
  object Memo1: TMemo
    Left = 8
    Top = 8
    Width = 337
    Height = 153
    Lines.Strings = (
      'Memo1')
    TabOrder = 0
  end
  object ImageList1: TImageList
    BkColor = clOlive
    Left = 128
    Top = 56
    Bitmap = {
      494D474C01000100100000001000000004000000424D360C0000000000003600
      00002800000020000000200000000100180000000000000C0000120B0000120B
      0000000000000000000000828400828400828400828400828400828400828400
      8284008284008284008284008284008284008284008284008284008284008284
      0082840082840082840082840082840082840082840082840082840082840082
      84008284008284008284008284008284008284008284008284FFFFFF7B7D7B00
      00FF7B7D7BFFFFFF008284008284008284008284008284008284008284008284
      0082840082840082840082840082840082840082840082840082840082840082
      8400828400828400828400828400828400828400FFFFFFFFFF00FFFF0000FF00
      00FF0000FF00FFFFFFFFFF00FFFF008284008284008284008284000000000000
      0082840000000000000000000000000000000000000000000082840082840000
      0000000000000000000000828400828400FFFFFFFFFF00FFFFFFFFFF7B7D7B00
      00FF7B7D7BFFFFFF00FFFFFFFFFF00FFFF008284008284008284000000008284
      0082840082840000000000000082840082840000000082840082840082840082
      8400000000000000828400828400FFFFFFFFFF00FFFFFFFFFF00FFFFFFFFFF00
      FFFFFFFFFF00FFFFFFFFFF00FFFFFFFFFF00FFFF0082840082847B7D7B000000
      0000000000000000007B7D7B0082840082840000000082840082840082840082
      84000000000000008284008284FFFFFF00FFFFFFFFFF00FFFFFFFFFF00FFFF00
      00FF00FFFFFFFFFF00FFFFFFFFFF00FFFFFFFFFF008284008284008284000000
      0082840000000000000082840082840082847B7D7B0000000000000000000000
      000000007B7D7B008284FFFFFF00FFFFFFFFFF00FFFFFFFFFF00FFFFFFFFFF00
      00FF7B7D7B00FFFFFFFFFF00FFFFFFFFFF00FFFFFFFFFF008284008284000000
      0082840000007B7D7B0082840082840082840082840000000082840082840000
      0000000000828400828400FFFFFFFFFF00FFFFFFFFFF00FFFFFFFFFF00FFFF00
      00FF0000FFFFFFFF00FFFFFFFFFF00FFFFFFFFFF00FFFF0082840082847B7D7B
      0000000000007B7D7B0082840082840082840082840000000082840082840000
      00000000008284008284FFFFFF00FFFFFFFFFF00FFFFFFFFFF00FFFFFFFFFF00
      FFFF0000FF0000FFFFFFFF00FFFFFFFFFF00FFFFFFFFFF008284008284008284
      0000000000000082840082840082840082840082847B7D7B0000000082840000
      007B7D7B00828400828400FFFFFFFFFF00FFFFFFFFFF7B7D7B7B7D7B00FFFFFF
      FFFF7B7D7B0000FF0000FFFFFFFF00FFFFFFFFFF00FFFF008284008284008284
      0000007B7D7B0082840082840082840082840082840082840000000000000000
      00008284008284008284FFFFFF00FFFFFFFFFF00FFFF0000FF0000FFFFFFFF00
      FFFF7B7D7B0000FF0000FF00FFFFFFFFFF00FFFFFFFFFF008284008284008284
      0082840082840000FF0000FF0082840000FF0082840082840000000000000000
      00008284008284008284008284FFFFFF00FFFFFFFFFF0000FF0000FF7B7D7BFF
      FFFF7B7D7B0000FF0000FFFFFFFF00FFFFFFFFFF008284008284008284008284
      0082840082840082840082840000FF0000FF0000FF0082840082840000007B7D
      7B00828400828400828400828400FFFFFFFFFF00FFFFFFFFFF0000FF0000FF00
      00FF0000FF0000FFFFFFFF00FFFFFFFFFF00FFFF008284008284008284008284
      0082840082840082840082840000FF0000FF0000FF0000FF0082840000000082
      8400828400828400828400828400828400FFFFFFFFFF00FFFFFFFFFF0000FF00
      00FF0000FFFFFFFF00FFFFFFFFFF00FFFF008284008284008284008284008284
      0082840082840082840082840082840082840082840082840082840082840082
      8400828400828400828400828400828400828400FFFFFFFFFF00FFFFFFFFFF00
      FFFFFFFFFF00FFFFFFFFFF00FFFF008284008284008284008284008284008284
      0082840082840082840082840082840082840082840082840082840082840082
      84008284008284008284008284008284008284008284008284FFFFFF00FFFFFF
      FFFF00FFFFFFFFFF008284008284008284008284008284008284008284008284
      0082840082840082840082840082840082840082840082840082840082840082
      8400828400828400828400828400828400828400828400828400828400828400
      828400FFFF00828400828400828400828400828400828400FFFF008284008284
      0000000000000000000000000000000000000000000000000000000000000000
      0000828400828400828400828400FFFF00FFFF0082847B7D7B7B7D7B7B7D7B00
      FFFF00FFFF7B7D7B7B7D7B7B7D7B7B7D7B00FFFF00FFFF008284008284008284
      00000000008400FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF0000
      0000828400828400828400828400828400FFFF00000000000000000000000000
      000000000000000000000000000000000000FFFF008284008284008284008284
      00000000008400008400FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF0000
      00008284008284008284008284008284008284000000FFFFFFFFFFFFFFFFFFFF
      FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000007B7D7B008284008284008284008284
      00000000008400008400008400FFFF00FFFF00FFFF00FFFF00FFFF00FFFF0000
      00008284008284008284008284008284008284000000FFFFFFFFFFFFFFFFFFFF
      FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000007B7D7B008284008284008284008284
      00000000008400008400008400000000FFFF00FFFF00FFFF00FFFF00FFFF0000
      00008284008284008284008284008284008284000000FFFFFF000000000000FF
      FFFF000000000000000000FFFFFF0000007B7D7B008284008284008284008284
      00000000008400008400008400000000FFFF00FFFF00FFFF00FFFF00FFFF0000
      00008284008284008284008284008284008284000000FFFFFFFFFFFFFFFFFFFF
      FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000007B7D7B008284008284008284008284
      00000000008400008400008400000000FFFF00FFFF00FFFF00FFFF00FFFF0000
      0000828400828400828400FFFF00FFFF00FFFF000000FFFFFF00000000000000
      0000000000FFFFFF000000FFFFFF00000000FFFF00FFFF008284008284008284
      00000000008400008400008400000000FFFF00FFFF00FFFF00FFFF00FFFF0000
      0000828400828400828400828400FFFF00FFFF000000FFFFFFFFFFFFFFFFFFFF
      FFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFF00FFFF00FFFF008284008284
      00000000008400008400008400000000FFFF00FFFF00FFFF00FFFF00FFFF0000
      00008284008284008284008284008284008284000000FFFFFF000000000000FF
      FFFF000000000000000000000000000000008284008284008284008284008284
      00000000008400008400008400000000FFFF00FFFF00FFFF00FFFF00FFFF0000
      00008284008284008284008284008284008284000000FFFFFFFFFFFFFFFFFFFF
      FFFF000000FFFFFFFFFFFF000000008284008284008284008284008284008284
      00000000008400008400008400FFFF00000000FFFF00FFFF00FFFF00FFFF0000
      00008284008284008284008284008284008284000000FFFFFF000000BDBEBDFF
      FFFF000000FFFFFF00000000FFFF008284008284008284008284008284008284
      00000000008400008400008400000000FFFF00FFFF00FFFF00FFFF00FFFF0000
      00008284008284008284008284008284008284000000FFFFFFFFFFFFFFFFFFFF
      FFFF00000000000000828400FFFF00FFFF008284008284008284008284008284
      00000000008400008400008400000000FFFF00FFFF00FFFF00FFFF00FFFF0000
      0000828400828400828400828400828400FFFF00000000000000000000000000
      000000000000828400828400828400FFFF00FFFF008284008284008284008284
      000000000084FFFF0000008400000000FFFF00FFFF00FFFF00FFFF00FFFF0000
      0000828400828400828400828400FFFF00FFFF00828400828400828400828400
      FFFF00FFFF00828400828400828400828400FFFF00FFFF008284008284008284
      000000000084FFFF00FFFF0000000000FFFF00FFFF00FFFF00FFFF00FFFF0000
      0000828400828400828400FFFF00828400828400828400828400828400828400
      FFFF00828400828400828400828400828400828400828400FFFF008284008284
      0000000000000000000000000000000000000000000000000000000000000000
      00008284008284008284424DBE000000000000003E0000002800000020000000
      20000000010001000000000080000000120B0000120B00000200000002000000
      FFFFFF00000000000000000007C000001FF0DFCF3FF88C867FFCFC867FFC58FE
      FFFE584CFFFE784CFFFE306CFFFE3038FFFE0D387FFC03987FFC03D03FF80000
      1FF0000007C0000000813FF86FFE3FF83FFC3FF81FFC3FF81FFC3FF81FFC3FF8
      1FFC3FF8FFFE3FF87FFF3FF81FF83FF81FF03FF81FF03FF81FD83FF83F8C3FF8
      61863FF881013FF8}
  end
  object MainMenu1: TMainMenu
    Images = ImageList1
    Left = 64
    Top = 56
    object File1: TMenuItem
      Caption = '&File'
      object New1: TMenuItem
        Caption = '&New'
        ImageIndex = 0
        OnClick = New1Click
      end
      object LargeFont1: TMenuItem
        Caption = '&Large Font'
        ImageIndex = 3
        ShortCut = 16454
        OnClick = LargeFont1Click
      end
      object Close1: TMenuItem
        Caption = 'E&xit'
        ImageIndex = 1
        ShortCut = 36915
        OnClick = Close1Click
      end
    end
    object Help1: TMenuItem
      Caption = '&Help'
      object About1: TMenuItem
        Caption = '&About...'
        ImageIndex = 2
        OnClick = About1Click
      end
    end
  end
end