I'm trying to create a TScrollBox with flat border instead of the ugly "Ctl3D" one.
Here is what I have tried, yet the border is not visible:
type
TScrollBox = class(Forms.TScrollBox)
private
procedure WMNCPaint(var Message: TWMNCPaint); message WM_NCPAINT;
protected
public
constructor Create(AOwner: TComponent); override;
end;
...
constructor TScrollBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
BorderStyle := bsNone;
BorderWidth := 1; // This will handle the client area
end;
procedure TScrollBox.WMNCPaint(var Message: TWMNCPaint);
var
DC: HDC;
R: TRect;
FrameBrush: HBRUSH;
begin
inherited;
DC := GetWindowDC(Handle);
GetWindowRect(Handle, R);
// InflateRect(R, -1, -1);
FrameBrush := CreateSolidBrush(ColorToRGB(clRed)); // clRed is here for testing
FrameRect(DC, R, FrameBrush);
DeleteObject(FrameBrush);
ReleaseDC(Handle, DC);
end;
What am I doing wrong?
I would like to customize the border color & width so I can't use BevelKind = bkFlat
, plus bkFlat
"breaks" with RTL BidiMode and looks really bad.