TControl自由移动变化大小 assigned(Panel1.onMouseMoe)判断修改移动事件

procedure ManipulateControl(Control: TControl; Shift: TShiftState; X, Y, Precision: integer);
var
Form1: TForm1;

implementation

{$R *.dfm}

// 任意改变一个控件 ( 拖动、放大、缩小 )
procedure ManipulateControl(Control: TControl; Shift: TShiftState; X, Y, Precision: integer);
var SC_MANIPULATE: Word;
begin
if (X<=Precision) and (Y>Precision) and (Y<Control.Height-Precision) then // 光标在控件的最左侧
begin
SC_MANIPULATE := $F001;
Control.Cursor := crSizeWE;
end
else
if (X>=Control.Width-Precision) and (Y>Precision) and (Y<Control.Height-Precision) then // 光标在控件的最右侧
begin
SC_MANIPULATE := $F002;
Control.Cursor := crSizeWE;
end
else
if (X>Precision) and (X<Control.Width-Precision) and (Y<=Precision) then // 光标在控件的最上侧
begin
SC_MANIPULATE := $F003;
Control.Cursor := crSizeNS;
end
else
if (X<=Precision) and (Y<=Precision) then // 光标在控件的左上角
begin
SC_MANIPULATE := $F004;
Control.Cursor := crSizeNWSE;
end
else
if (X>=Control.Width-Precision) and (Y<=Precision) then // 光标在控件的右上角
begin
SC_MANIPULATE := $F005;
Control.Cursor := crSizeNESW;
end
else
if (X>Precision) and (X<Control.Width-Precision) and (Y>=Control.Height-Precision) then // 光标在控件的最下侧
begin
SC_MANIPULATE := $F006;
Control.Cursor := crSizeNS;
end
else
if (X<=Precision) and (Y>=Control.Height-Precision) then // 光标在控件的左下角
begin
SC_MANIPULATE := $F007;
Control.Cursor := crSizeNESW;
end
else
if (X>=Control.Width-Precision) and (Y>=Control.Height-Precision) then // 光标在控件的右下角
begin
SC_MANIPULATE := $F008;
Control.Cursor := crSizeNWSE;
end
else
if (X>5) and (Y>5) and (X<Control.Width-5) and (Y<Control.Height-5) then // 光标在控件的客户区 ( 移动整个控件 )
begin
SC_MANIPULATE := $F009;
Control.Cursor := crSizeAll;
end
else
begin
SC_MANIPULATE := $F000;
Control.Cursor := crDefault;
end;
if Shift=[ssLeft] then
begin
ReleaseCapture;
Control.Perform(WM_SYSCOMMAND, SC_MANIPULATE, 0);
end;
end;
procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
ManipulateControl((Sender as TControl), Shift, X, Y, 8);
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
if Assigned(Panel1.onMouseMove) then
begin
((Sender as TControl).Parent as TPanel).OnMouseMove:=nil;
((Sender as TControl).Parent as TPanel).Cursor:=crDefault;
end
else
begin
((Sender as TControl).Parent as TPanel).Cursor:=crSizeAll;
((Sender as TControl).Parent as TPanel).OnMouseMove:=Panel1MouseMove;
end;
end;

TControl自由移动变化大小 assigned(Panel1.onMouseMoe)判断修改移动事件html

转载于:https://www.cnblogs.com/tk-del/archive/2012/02/24/2366930.htmlpost