打印本文 打印本文 关闭窗口 关闭窗口
控件移动类的实现之二
作者:武汉SEO闵涛  文章来源:敏韬网  点击数6986  更新时间:2009/4/23 18:30:39  文章录入:mintao  责任编辑:mintao
on: TMouseButton;

      Shift: TShiftState; X, Y: Integer);

 

      procedure SetisMoveStep(value:Boolean);

      procedure SetMoveStep(value:integer);

    public

      constructor create(PointParent:TWinControl);

      destructor destroy; override;

      function addControl(AddCon:Pointer):Boolean;  //important

      procedure SetPointVisible(Visibled:Boolean);

      property isMoveStep:Boolean read FisMoveStep write SetisMoveStep;

      property MoveStep:Integer read FMoveStep write SetMoveStep;

    end;

 

implementation

 

{ TDragClass }

 

constructor TDragClass.create(PointParent:TWinControl);

begin

  inherited Create;

  FConList:=TList.Create;

  FCurActiveCon:=-1;

  isDown:=False;

  FisMoveStep:=False;

  FMoveStep:=5;

 

  FConMouseDown:=ConMouseDown;

  FConMouseMove:=ConMouseMove;

  FConMouseup:=ConMouseUp;

 

  CreateDragPoint(PointParent);

  SetPointVisible(false);

  SetPointEvent;

end;

 

destructor TDragClass.destroy;

begin

  FreeAndNil(FConList);

  FPointRec.LeftTop.Free;

  FPointRec.LeftBottom.Free;

  FPointRec.RightTop.Free;

  FPointRec.RightButton.Free;

  FPointRec.LeftMid.Free;

  FPointRec.TopMid.Free;

  FPointRec.RightMid.Free;

  FPointRec.ButtonMid.Free;

  inherited;

end;

//加一个控件进入拖拉类

function TDragClass.addControl(AddCon: Pointer): Boolean;

var TempCon:TControl; R:TRect;

    i:integer;

begin

  result:=True;

  if TControl(AddCon).Parent=nil then

  begin

    result:=false;

    exit;

  end;

  //如果该控件已经在列表中了,则加入失败

  for i:=0 to FConList.Count-1 do

    if Integer(AddCon)=Integer(FConList.Items[i]) then

    begin

      result:=false;

      exit;

    end;

  //将控件加入列表中,并指定当前的控件的索引

  FConList.Add(AddCon);

  FCurActiveCon:=FConList.Count-1;

  TempCon:=TControl(AddCon);

  TempCon.Cursor:=crSizeAll;

  TempCon.Parent.DoubleBuffered:=True;  //使用双缓冲技术

  //折中方案,指定控件鼠标事件

  TButton(TempCon).OnMouseDown:=FconMouseDown;

  TButton(TempCon).OnMouseMove:=FconMouseMove;

  TButton(TempCon).OnMouseUp:=FconMouseUp;

  //画控件周围的八个小点

  R.Left:=TempCon.Left;

  R.Top:=TempCon.Top;

  R.Right:=TempCon.Left+TempCon.Width;

  R.Bottom:=TempCon.Top+TempCon.Height;

  SetPointParent(TempCon.Parent);

  SetPointPos(R);

  SetPointVisible(true);

end;

//设置八小点的可见性

procedure TDragClass.SetPo

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ...  下一页 >> 

打印本文 打印本文 关闭窗口 关闭窗口