procedure TRVButton.FreeRegion;
begin
if FKRgn <> 0 then DeleteObject(FKRgn);
FKRgn := 0;
end;
procedure TRVButton.MoveButton;
var
Color1: TColor;
Color2: TColor;
begin
with Canvas do
begin
if not FLButtonDown then
begin
Color1 := clBtnHighlight;
Color2 := clBtnShadow;
end
else
begin
Color1 := clBtnShadow;
Color2 := clBtnHighLight;
end;
Pen.Width := 1;
if FLButtonDown then Pen.Color := clBlack
else Pen.Color := Color2;
procedure TRVButton.Paint;
begin
inherited Paint;
FreeRegion;
DrawCircle;
end;
procedure TRVButton.SetButtonColor(Value: TColor);
begin
if Value <> FButtonColor then
begin
FButtonColor := Value;
Invalidate;
end;
end;
procedure TRVButton.SetCaption(Value: string);
var
X: Integer;
Y: Integer;
begin
if ((Value <> FCaption) and (Value <> '')) then
begin
FCaption := Value;
end;
with Canvas.Font do
begin
Name := Font.Name;
Size := Font.Size;
Style := Font.Style;
if Self.Enabled then Color := Font.Color
else
Color := clDkGray;
end;
X := (Width div 2) - (Canvas.TextWidth(FCaption) div 2);
Y := (Height div 2) - (Canvas.TextHeight(FCaption) div 2);
Canvas.TextOut(X, Y, FCaption);
// Invalidate;
end;
procedure TRVButton.WMLButtonDown(var Message: TWMLButtonDown);
begin
if not PtInRegion(FKRgn,Message.xPos,Message.yPos) then exit;
FLButtonDown := True;
MoveButton;
inherited;
end;
procedure TRVButton.WMLButtonUp(var Message: TWMLButtonUp);
begin
if not FLButtonDown then exit;
FLButtonDown := False;
MoveButton;
inherited;
end;