TXXEdit = class(TEdit)
private
FBorderColor: TColor;
procedure ReDrawBorder;
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
procedure SetBorderColor(const Value: TColor);
public
constructor Create(AOwner: TComponent); override;
published
property BorderColor: TColor read FBorderColor write SetBorderColor
default BORDER_COLOR;
end;
{ TXXEdit }
constructor TXXEdit.Create(AOwner: TComponent);
begin
inherited;
FBorderColor := BORDER_COLOR;
ParentCtl3D := False;
Ctl3D := False;
end;
procedure TXXEdit.ReDrawBorder;
var
DC: HDC;
Rect: TRect;
BorderBrush: HBRUSH;
begin
if Ctl3D or (BorderStyle = bsNone) or (FBorderColor = DEF_BORDER_COLOR) then
exit;
DC := GetWindowDC(Handle);
try
if not GetWindowRect(Handle, Rect) then
exit;
OffsetRect(Rect, -Rect.Left, -Rect.Top);
BorderBrush := CreateSolidBrush(ColorToRGB(FBorderColor));
FrameRect(DC, Rect, BorderBrush);
DeleteObject(BorderBrush);
finally
ReleaseDC(Handle, DC);
end;
end;
procedure TXXEdit.SetBorderColor(const Value: TColor);
begin
FBorderColor := Value;
if HandleAllocated then
ReDrawBorder;
end;
procedure TXXEdit.WMPaint(var Message: TWMPaint);
begin
inherited;
ReDrawBorder;
end;
//给分吧,谢谢