若要自定工具拦,但也要保留windows样式的按钮时
下面给出一种实现
procedure TmyButton.defaultdraw;
var arect,R:Trect;
wpos,hpos:integer;
Details: TThemedElementDetails;
begin
hpos:=0;
arect:=self.ClientRect;
canvas.Font:=font;
canvas.Brush.Color:=$CCFFFF;
if assigned(fimagelist) then
begin
if (fimagelist.Count>0) or (fimage>=0) then
begin
wpos:=(width-imagelist.Width) div 2;
if fhot and ( not (csDesigning in ComponentState) ) then
begin
R:=rect(wpos-8,0,wpos+fimagelist.width+8,fimagelist.Height+16);
if ThemeServices.ThemesEnabled then
begin
if fdown then
begin
Details := ThemeServices.GetElementDetails(themes.ttbButtonPressed);
end
else
Details :=