完全透明的控件,可以获得事件
type
TxControl=class(TWinControl)
private
procedure CreateParams(var Params: TCreateParams); override;
procedure xControlMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
{ TControl }
constructor TxControl.Create(AOwner: TComponent);
begin
inherited;
ControlStyle :=ControlStyle - [csOpaque];
self.OnMouseDown:=self.xControlMouseDown;
end;
procedure TxControl.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do
begin
{ 完全重画 }
Style := Style and not WS_CLIPCHILDREN;
Style := Style and not WS_CLIPSIBLINGS;
{ 增加透明 }
ExStyle := ExStyle or WS_EX_TRANSPARENT;
end;
end;
destructor TxControl.Destroy;
begin
inherited;
end;
procedure TxControl.xControlMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
SendMessage(self.Parent.Handle,WM_SYSCOMMAND,SC_MOVE+HTCaption,0);
end;