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;
procedure Register;
begin
RegisterComponents('CX Lib', [TTransButton]);
end;
procedure TTransButton.SetTransparent(Value: Boolean);
begin
if ftransparent <> value then
begin
ftransparent := value;
if value then
controlstyle := controlstyle - [csOpaque]
else
controlstyle := controlstyle + [csOpaque];
invalidate;
end;
end;
procedure TTransButton.WMEraseBkgnd(var Msg: TMessage);
var
br: HBRUSH;
begin
if ftransparent then
msg.result := 1
else
inherited;
end;
procedure TTransButton.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
params.exstyle := params.exstyle or WS_EX_TRANSPARENT;
end;
procedure TTransButton.SetParent(AParent: TWinControl);
begin
inherited SetParent(AParent);
if (aparent <> nil) and aparent.HandleAllocated
and (GetWindowLong(aparent.Handle, GWL_STYLE) or WS_CLIPCHILDREN <> 0) then
SetWindowLong(aparent.handle, GWL_STYLE, GetWindowLong(aparent.Handle, GWL_STYLE)
and not WS_CLIPCHILDREN);
end;