Logo New book: Delphi 2007 Handbook
My blog in online
Delphi tech support service: support.marcocantu.com
Google
  Web www.marcocantu.com

Menu for Development

Site Menu
Delphi 2007 Handbook
Mastering Borland Delphi 2005
Essential Pascal
Essential Delphi
Buy Books Online
Code Repository
Newsgroups
White Papers
Tools
Conferences
Training
Delphi Links
Contact Marco

My Other Sites
Italian Site (www.marcocantu.it)
Developers Newsgroups Browser (dev.newswhat.com)
My town (www.piazzacavalli.net)
the delphi search
Wintech Italia (my company)

Breaking News
Buy Mastering Borland Delphi 2005 from Amazon
Free ebook: Mastering Delphi Update for Delphi 2006

Advertising
Home My Blog Books My Bookstore Development Links Marco



Home: Code Repository: Mastering Delphi 5

Project NEWCHECK

Project Structure


NEWCHECK.DPR

program Newcheck;

uses
  Forms,
  CHECK in 'CHECK.PAS' {Form1};

{$R *.RES}

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

CHECK.PAS

unit Check;

interface

uses Windows, Classes, Graphics, Forms, Controls, Menus,
  StdCtrls;

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    Command1: TMenuItem;
    Toggle1: TMenuItem;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Toggle1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    Bmp1, Bmp2: TBitmap;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Bmp1 := TBitmap.Create;
  Bmp2 := TBitmap.Create;
  Bmp1.LoadFromFile ('ok.bmp');
  Bmp2.LoadFromFile ('no.bmp');

  {Windows API call}
  SetMenuItemBitmaps (Command1.Handle, Toggle1.Command, MF_BYCOMMAND,
    Bmp2.Handle, Bmp1.Handle);
end;

procedure TForm1.Toggle1Click(Sender: TObject);
begin
  Toggle1.Checked := not Toggle1.Checked;
  if Toggle1.Checked then
    Label1.Caption := 'ON'
  else
    Label1.Caption := 'OFF';
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Bmp1.Free;
  Bmp2.Free;
end;

end.

CHECK.DFM

object Form1: TForm1
  Left = 97
  Top = 243
  Width = 435
  Height = 235
  Caption = 'New Check'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -13
  Font.Name = 'System'
  Font.Style = []
  Menu = MainMenu1
  OldCreateOrder = True
  OnCreate = FormCreate
  OnDestroy = FormDestroy
  PixelsPerInch = 96
  TextHeight = 16
  object Label1: TLabel
    Left = 0
    Top = 48
    Width = 425
    Height = 111
    Alignment = taCenter
    AutoSize = False
    Caption = 'OFF'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -96
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object MainMenu1: TMainMenu
    Left = 8
    Top = 8
    object Command1: TMenuItem
      Caption = '&Command'
      object Toggle1: TMenuItem
        Caption = '&Toggle'
        OnClick = Toggle1Click
      end
    end
  end
end