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 MenuImg

Project Structure

MenuImg.dpr
program MenuImg;

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

{$R *.RES}

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

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Menus, ImgList;

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 *.DFM}

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.dfm
object Form1: TForm1
  Left = 192
  Top = 107
  Width = 356
  Height = 216
  Caption = 'Menu Images'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  Menu = MainMenu1
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Memo1: TMemo
    Left = 8
    Top = 8
    Width = 337
    Height = 153
    Lines.Strings = (
      'Memo1')
    TabOrder = 0
  end
  object ImageList1: TImageList
    Left = 128
    Top = 56
    Bitmap = {
      494C010104000500040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
      0000000000003600000028000000400000002000000001001000000000000010
      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
      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
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000E07F000000000000000000000000E07F0000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000E07FE07F0000104210421042
      E07FE07F1042104210421042E07FE07F00000000000000000040E07FE07FE07F
      E07FE07FE07FE07FE07F000000000000000000000000000000000000FF7F1042
      007C1042FF7F0000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000000000000000E07F0000000000000000
      000000000000000000000000E07F0000000000000000000000400040E07FE07F
      E07FE07FE07FE07FE07F0000000000000000000000000000E07FFF7FE07F007C
      007C007CE07FFF7FE07F00000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000FF7FFF7FFF7F
      FF7FFF7FFF7FFF7FFF7F0000104200000000000000000000004000400040E07F
      E07FE07FE07FE07FE07F000000000000000000000000E07FFF7FE07FFF7F1042
      007C1042FF7FE07FFF7FE07F0000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000FF7FFF7FFF7F
      FF7FFF7FFF7FFF7FFF7F00001042000000000000000000000040004000400000
      E07FE07FE07FE07FE07F00000000000000000000E07FFF7FE07FFF7FE07FFF7F
      E07FFF7FE07FFF7FE07FFF7FE07F000000001042000000000000000010420000
      0000000000000000000000000000000000000000000000000000FF7FFF7FFF7F
      FF7FFF7FFF7FFF7FFF7F00001042000000000000000000000040004000400000
      E07FE07FE07FE07FE07F00000000000000000000FF7FE07FFF7FE07FFF7FE07F
      007CE07FFF7FE07FFF7FE07FFF7F000000000000000000000000000000000000
      0000104200000000000000000000104200000000000000000000FF7FFF7FFF7F
      FF7FFF7FFF7FFF7FFF7F00001042000000000000000000000040004000400000
      E07FE07FE07FE07FE07F0000000000000000FF7FE07FFF7FE07FFF7FE07FFF7F
      007C1042E07FFF7FE07FFF7FE07FFF7F00000000000000000000104200000000
      000000000000000000000000000000000000E07FE07FE07F0000FF7FFF7FFF7F
      FF7FFF7FFF7FFF7FFF7F0000E07FE07F00000000000000000040004000400000
      E07FE07FE07FE07FE07F0000000000000000E07FFF7FE07FFF7FE07FFF7FE07F
      007C007CFF7FE07FFF7FE07FFF7FE07F00000000104200000000104200000000
      0000000000000000000000000000000000000000E07FE07F0000FF7FFF7FFF7F
      FF7FFF7FFF7FFF7FFF7F0000E07FE07FE07F0000000000000040004000400000
      E07FE07FE07FE07FE07F0000000000000000FF7FE07FFF7FE07FFF7FE07FFF7F
      E07F007C007CFF7FE07FFF7FE07FFF7F00000000000000000000000000000000
      0000000010420000000000001042000000000000000000000000FF7FFF7FFF7F
      FF7F000000000000000000000000000000000000000000000040004000400000
      E07FE07FE07FE07FE07F0000000000000000E07FFF7FE07FFF7F10421042E07F
      FF7F1042007C007CFF7FE07FFF7FE07F00000000000000001042000000000000
      0000000000000000000000000000000000000000000000000000FF7FFF7FFF7F
      FF7F0000FF7FFF7F00000000000000000000000000000000004000400040E07F
      0000E07FE07FE07FE07F0000000000000000FF7FE07FFF7FE07F007C007CFF7F
      E07F1042007C007CE07FFF7FE07FFF7F00000000000000000000007C007C0000
      007C000000000000000000000000000000000000000000000000FF7FFF7FFF7F
      FF7F0000FF7F0000E07F00000000000000000000000000000040004000400000
      E07FE07FE07FE07FE07F00000000000000000000FF7FE07FFF7F007C007C1042
      FF7F1042007C007CFF7FE07FFF7F00000000000000000000000000000000007C
      007C007C00000000000010420000000000000000000000000000FF7FFF7FFF7F
      FF7F000000000000E07FE07F0000000000000000000000000040004000400000
      E07FE07FE07FE07FE07F00000000000000000000E07FFF7FE07FFF7F007C007C
      007C007C007CFF7FE07FFF7FE07F00000000000000000000000000000000007C
      007C007C007C00000000000000000000000000000000E07F0000000000000000
      00000000000000000000E07FE07F000000000000000000000040FF0300400000
      E07FE07FE07FE07FE07F000000000000000000000000E07FFF7FE07FFF7F007C
      007C007CFF7FE07FFF7FE07F0000000000000000000000000000000000000000
      0000000000000000000000000000000000000000E07FE07F0000000000000000
      E07FE07F0000000000000000E07FE07F00000000000000000040FF03FF030000
      E07FE07FE07FE07FE07F0000000000000000000000000000E07FFF7FE07FFF7F
      E07FFF7FE07FFF7FE07F00000000000000000000000000000000000000000000
      000000000000000000000000000000000000E07F000000000000000000000000
      E07F0000000000000000000000000000E07F0000000000000000000000000000
      00000000000000000000000000000000000000000000000000000000FF7FE07F
      FF7FE07FFF7F0000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000424D3E000000000000003E000000
      2800000040000000200000000100010000000000000100000000000000000000
      000000000000000000000000FFFFFF0000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000FF7EC007FFFFFFFF9001C007F83FFFFF
      C003C007E00F2030E003C007C0077379E003C00780030379E003C0078003A701
      E003C0070001A7B30001C007000187B38000C0070001CF93E007C0070001CFC7
      E00FC0070001F2C7E00FC0078003FC67E027C0078003FC2FC073C007C007FFFF
      9E79C007E00FFFFF7EFEC007F83FFFFF00000000000000000000000000000000
      000000000000}
  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 = 32883
        OnClick = Close1Click
      end
    end
    object Help1: TMenuItem
      Caption = '&Help'
      object About1: TMenuItem
        Caption = '&About...'
        ImageIndex = 2
        OnClick = About1Click
      end
    end
  end
end