重载CreateWnd只是在静态下有效,如果改变控件的大小,则形状会有变化.
再重载SetBounds问题才可全面解决.
type
TRbutton=class(TButton)
private
.......
protected
procedure CreateWnd;override;
...
public
procedure SetBounds(ALeft,ATop,AWidth,AHeight : integer);override;
...
procedure TRButton.SetBounds(ALeft,ATop,AWidth,AHeight : integer);
begin
inherited SetBounds(ALeft,ATop,AWidth,AHeight);
if HandleAllocated then
begin
hRgn:=CreateEllipticRgn(0,0,Width,Height);//创建一个椭圆剪裁域;
SetWindowRgn(Handle,hRgn,True);//将此控件设置为椭圆形的OKEY!
end;
end;
然后用拖拽即可实现移动.
另外: Delphi Image edit只对Icon有透明色,对其他Image则应使用clOlive,即
橄榄色(颜色区上排第四个).