//聲明:
MoveToEx(
DC: HDC; {設備環境句柄}
p2, p3: Integer; {坐標}
p4: PPoint {用於保存 p2、p3 值的 TPoint 結構的指針}
): BOOL;
LineTo(
DC: HDC; {設備環境句柄}
X, Y: Integer {直線終點坐標}
): BOOL;
//舉例:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
flag: Boolean;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
MoveToEx(Canvas.Handle, X, Y, nil);
flag := True;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if flag then LineTo(Canvas.Handle, X, Y);
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
flag := False;
end;
end.
//效果圖: