udragpoint.pas

来自「运行时设计控件的一个小例子」· PAS 代码 · 共 56 行

PAS
56
字号
//---------TDragPoint--------------------------
unit UDragPoint;

interface

uses Windows, Messages,Controls,Classes,Graphics;

type
  TDragPoint=class(TCustomControl)
  protected
    procedure Paint;override;
  public
    //处理移动时用的变量
    isDown:Boolean;
    PrevP,NextP:TPoint;
    constructor Create(AOwner: TComponent); override;
    procedure CreateWnd; override;
  published
    property OnMouseMove;
    property OnMouseDown;
    property OnMouseUp;
  end;

implementation

{ TDragPoint }

//----------------------------------------------------------------------------//
constructor TDragPoint.Create;
begin
  inherited Create(AOwner);
  isDown:=False;
  Width:=5;
  Height:=5;
end;

//----------------------------------------------------------------------------//
procedure TDragPoint.CreateWnd;
begin
  inherited;
    //使该类位窗口最前
    BringWindowToTop(self.Handle);
end;

//----------------------------------------------------------------------------//
procedure TDragPoint.Paint;
begin
  Canvas.Brush.Color:=clBlack;
  Canvas.Brush.Style:=bsSolid;
  Canvas.Rectangle(0,0,width,Height);
end;

//----------------------------------------------------------------------------//
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?