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 09 - Project Scale

Project Structure

Scale.dpr
program Scale;

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

{$R *.RES}

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

interface

uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, Spin, Mask, ComCtrls;

type
  TForm1 = class(TForm)
    ScaleButton: TButton;
    RestoreButton: TButton;
    Label1: TLabel;
    Edit1: TEdit;
    UpDown1: TUpDown;
    procedure ScaleButtonClick(Sender: TObject);
    procedure RestoreButtonClick(Sender: TObject);
  private
    { Private declarations }
    AmountScaled: Integer;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.ScaleButtonClick(Sender: TObject);
begin
  AmountScaled := UpDown1.Position;
  ScaleBy (AmountScaled, 100);
  UpDown1.Height := Edit1.Height;
  ScaleButton.Enabled := False;
  RestoreButton.Enabled := True;
end;

procedure TForm1.RestoreButtonClick(Sender: TObject);
begin
  ScaleBy (100, AmountScaled);
  UpDown1.Height := Edit1.Height;
  ScaleButton.Enabled := True;
  RestoreButton.Enabled := False;
end;

end.
ScaleF.dfm
object Form1: TForm1
  Left = 230
  Top = 133
  ActiveControl = ScaleButton
  AutoScroll = False
  Caption = 'Scale'
  ClientHeight = 139
  ClientWidth = 268
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clBlack
  Font.Height = -16
  Font.Name = 'Arial'
  Font.Style = [fsBold]
  OldCreateOrder = True
  PixelsPerInch = 96
  TextHeight = 19
  object Label1: TLabel
    Left = 24
    Top = 24
    Width = 69
    Height = 19
    Caption = '&ScaleBy:'
  end
  object ScaleButton: TButton
    Left = 144
    Top = 25
    Width = 97
    Height = 33
    Caption = '&Do Scale'
    TabOrder = 0
    OnClick = ScaleButtonClick
  end
  object RestoreButton: TButton
    Left = 144
    Top = 72
    Width = 97
    Height = 33
    Caption = '&Restore'
    Enabled = False
    TabOrder = 1
    OnClick = RestoreButtonClick
  end
  object Edit1: TEdit
    Left = 24
    Top = 48
    Width = 57
    Height = 27
    Color = clWindow
    TabOrder = 2
    Text = '100'
  end
  object UpDown1: TUpDown
    Left = 81
    Top = 48
    Width = 15
    Height = 27
    Associate = Edit1
    Min = 30
    Max = 300
    Increment = 10
    Position = 100
    TabOrder = 3
    Wrap = False
  end
end