все оказалось просто! :)
вот что я писал:
unit MoveControl;
interface
uses
SysUtils, Classes, Controls, Messages, WinProcs, Graphics;
type
TMoveEvent = procedure(Sender: TObject; const X, Y: Integer) of object;
TPaintEvent = procedure(Sender: TObject; Canvas: TCanvas) of object;
TMoveControl = class(TCustomControl)
private
FOnMove: TMoveEvent;
FOnPaint: TPaintEvent;
protected
procedure Paint; override;
procedure WMNCHITTEST(var Message : TMessage); message WM_NCHITTEST;
procedure WMMOVE(var Message : TMessage); message WM_MOVE;
public
constructor Create(AOwner: TComponent); override;
published
property OnMove: TMoveEvent read FOnMove write FOnMove;
property OnPaint: TPaintEvent read FOnPaint write FOnPaint;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TMoveControl]);
end;
constructor TMoveControl.Create(AOwner: TComponent);
begin
inherited;
Cursor := crSizeNWSE;
end;
procedure TMoveControl.Paint;
begin
inherited;
if not (csDesigning in ComponentState) and Assigned(OnPaint) then begin
FOnPaint(Self, Canvas);
end else begin
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := clRed;
Canvas.Pen.Color := clRed;
Canvas.FillRect(ClientRect);
end;
end;
procedure TMoveControl.WMMOVE(var Message: TMessage);
begin
if Assigned(FOnMove) then begin
FOnMove(Self, message.LParamLo, Message.LParamHi);
end;
end;
procedure TMoveControl.WMNCHITTEST(var Message: TMessage);
begin
if not (csDesigning in ComponentState) then begin
Message.Result := HTCAPTION;
end else
Message.Result := HTCLIENT;
end;
end.
компонент который можно двигать