const
HoverColor: TColor = TColor($00733800);
FocusColor: TColor = clBlue;
procedure DrawControlRect(AHandel: HWND; AColor: TColor);
// Diese Procedure habe ich im großen und ganzen bei
// den Jedis "geklaut"
var
LHDC: HDC;
LRect: TRect;
LCanvas: TCanvas;
begin
LHDC := GetWindowDC(AHandel);
try
GetWindowRect(AHandel, LRect);
OffsetRect(LRect, -LRect.Left, -LRect.Top);
LCanvas := TCanvas.Create;
with LCanvas
do
begin
try
Handle := LHDC;
Brush.Color := AColor;
FrameRect(LRect);
InflateRect(LRect, -1, -1);
FrameRect(LRect);
finally
Free;
end;
end;
finally
ReleaseDC(AHandel, LHDC);
end;
end;
procedure TForm1.AllEditEdit(Sender: TObject);
begin
DrawControlRect((Sender
as TWinControl).Handle, FocusColor);
end;
procedure TForm1.AlleditExit(Sender: TObject);
begin
(Sender
as TWinControl).Perform(CM_RECREATEWND, 0, 0);
end;
procedure TForm1.AllEditMouseEnter(Sender: TObject);
begin
with (Sender
as TWinControl)
do
begin
if not (Focused)
then
begin
DrawControlRect(
Handle, HoverColor);
end;
end;
end;
procedure TForm1.AllEditMouseLeave(Sender: TObject);
begin
with (Sender
as TWinControl)
do
begin
if not (Focused)
then
begin
(Sender
as TWinControl).Perform(CM_RECREATEWND, 0, 0);
end;
end;
end;