|
发表于 2020-2-20 11:45:03
|
显示全部楼层
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,jpeg,ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
fselecting:boolean;
fbeginpt,fendpt:tpoint;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
fselecting:=true;
fbeginpt:=Form1.ScreenToClient(mouse.CursorPos);
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
fselecting:=false;
fendpt:=Form1.ScreenToClient(mouse.CursorPos);
Self.Repaint;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
fendpt:=Form1.ScreenToClient(mouse.CursorPos);
if fselecting then
begin
Canvas.FillRect(Canvas.ClipRect);
//Canvas.Rectangle(rect(fbeginpt,fendpt));
canvas.Ellipse(rect(fbeginpt,fendpt));
canvas.Pen.Color:=clred;
Canvas.Pen.Width:=1;
end;
end;
end. |
|