可以继承一个,然后Override Paint事件:
看它的原码:
procedure TCustomGroupBox.Paint;
var
H: Integer;
R: TRect;
Flags: Longint;
begin
with Canvas do
begin
Font := Self.Font;
H := TextHeight('0');
R := Rect(0, H div 2 - 1, Width, Height);
if Ctl3D then
begin
Inc(R.Left);
Inc(R.Top);
Brush.Color := clBtnHighlight;<--
FrameRect(R);
OffsetRect(R, -1, -1);
Brush.Color := clBtnShadow;<--
end else
Brush.Color := clWindowFrame;<--
FrameRect(R);
if Text <> '' then
begin
if not UseRightToLeftAlignment then
R := Rect(8, 0, 0, H)
else
R := Rect(R.Right - Canvas.TextWidth(Text) - 8, 0, 0, H);
Flags := DrawTextBiDiModeFlags(DT_SINGLELINE);
DrawText(Handle, PChar(Text), Length(Text), R, Flags or DT_CALCRECT);
Brush.Color := Color;
DrawText(Handle, PChar(Text), Length(Text), R, Flags);
end;
end;
end;
使用SpinButton(samples页)加Edit