Marco Web Center

[an error occurred while processing this directive]

Home: Code Repository: Mastering Delphi 6

Chapter 09 - Project QScale

Project Structure

QScale.dpr
program QScale;

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

{$R *.res}

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

interface

uses
  SysUtils, Qt, Classes, QGraphics, QControls,
  QForms, QDialogs, QStdCtrls, Spin, QMask, QComCtrls;

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

var
  Form1: TForm1;

implementation

{$R *.xfm}

procedure TForm1.ScaleButtonClick(Sender: TObject);
begin
  AmountScaled := SpinEdit1.Value;
  ScaleBy (AmountScaled, 100);
  ScaleButton.Enabled := False;
  RestoreButton.Enabled := True;
end;

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

end.
ScaleF.xfm
object Form1: TForm1
  Left = 230
  Top = 133
  ActiveControl = ScaleButton
  AutoScroll = False
  Caption = 'Scale'
  ClientHeight = 139
  ClientWidth = 268
  Color = clButton
  Font.Color = clBlack
  Font.Height = 16
  Font.Name = 'Arial'
  Font.Pitch = fpVariable
  Font.Style = [fsBold]
  ParentFont = False
  PixelsPerInch = 96
  TextHeight = 19
  TextWidth = 9
  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 SpinEdit1: TSpinEdit
    Left = 24
    Top = 48
    Width = 65
    Height = 23
    Max = 200
    Min = 50
    Increment = 10
    TabOrder = 3
    Value = 100
  end
end