Blame | Last modification | View Log | Download
unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, ExtCtrls, ToolWin, ComCtrls;typeTForm1 = class(TForm)PaintBox1: TPaintBox;Button1: TButton;Button2: TButton;ScrollBar1: TScrollBar;procedure Button1Click(Sender: TObject);procedure Button2Click(Sender: TObject);procedure ScrollBar1Change(Sender: TObject);private{ Private declarations }public{ Public declarations }end;varForm1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);beginwith PaintBox1 do beginCanvas.Brush.Color := clRed;Canvas.Brush.Style := bsDiagCross;Canvas.Ellipse(0, 0, PaintBox1.Width, PaintBox1.Height);end;end;procedure TForm1.Button2Click(Sender: TObject);var Y: Integer;begin{ first call FillRect to paint the surface of the form.this removes any previously drawn lines (and anything else!)PaintBox1.Canvas.FillRect(ClientRect);}PaintBox1.Canvas.MoveTo(0, 0);PaintBox1.Canvas.LineTo(PaintBox1.Width,PaintBox1.Height);end;procedure TForm1.ScrollBar1Change(Sender: TObject);beginPaintBox1.Canvas.MoveTo(0,ScrollBar1.Position);PaintBox1.Canvas.LineTo(256,ScrollBar1.Position);end;end.