Logo Delphi Developer Days 2011

Menu for Development

Site Menu
Delphi 2010 Handbook
Delphi 2009 Handbook
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)

Advertising
Home My Blog Books My Bookstore Development Links Marco


Home: Code Repository: Mastering Delphi 6

Chapter 09 - Project QScroll2

Project Structure

QScroll2.dpr
program QScroll2;

uses
  QForms,
  ScrollF in 'ScrollF.pas' {Form2};

{$R *.res}

begin
  Application.CreateForm(TForm2, Form2);
  Application.Run;
end.
ScrollF.pas
unit ScrollF;

interface

uses
  Qt, SysUtils, Classes, QGraphics, QControls, QForms, QDialogs;

type
  TForm2 = class(TForm)
    procedure FormPaint(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.xfm}

procedure TForm2.FormPaint(Sender: TObject);
begin
  {draw a yellow line}
  Canvas.Pen.Width := 30;
  Canvas.Pen.Color := clYellow;
  Canvas.MoveTo (30 - HorzScrollbar.Position, 30 - VertScrollbar.Position);
  Canvas.LineTo (1970 - HorzScrollbar.Position, 1970 - VertScrollbar.Position);

  {draw a blue line}
  Canvas.Pen.Color := clNavy;
  Canvas.MoveTo (30 - HorzScrollbar.Position, 1970 - VertScrollbar.Position);
  Canvas.LineTo (1970 - HorzScrollbar.Position, 30 - VertScrollbar.Position);

  {draw a fuchsia square}
  Canvas.Pen.Color := clFuchsia;
  Canvas.Brush.Style := bsClear;
  Canvas.Rectangle (500 - HorzScrollbar.Position, 500 - VertScrollbar.Position,
    1500 - HorzScrollbar.Position, 1500 - VertScrollbar.Position);
end;

end.
ScrollF.xfm
object Form2: TForm2
  Left = 156
  Top = 112
  Width = 496
  Height = 379
  VertScrollBar.Range = 2000
  HorzScrollBar.Range = 2000
  AutoScroll = False
  Caption = 'Scroll2'
  Color = clButton
  Font.Color = clText
  Font.Height = 11
  Font.Name = 'MS Sans Serif'
  Font.Pitch = fpVariable
  Font.Style = []
  Font.Weight = 40
  ParentFont = False
  OnPaint = FormPaint
  PixelsPerInch = 96
  TextHeight = 13
  TextWidth = 6
end