![]() |
New book: Delphi 2007 Handbook My blog in online Delphi tech support service: support.marcocantu.com |
Menu for Development
|
|
| |||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||
| 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 |