随笔 - 2146  文章 - 97 评论 - 11767 trackbacks - 253

//声明:
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.
//效果图:

posted on 2008-02-09 15:58  万一  阅读(...)  评论(...编辑  收藏