我正在尝试创建一个带有扁平边框的 TScrollBox,而不是丑陋的“Ctl3D”。
这是我尝试过的,但边框不可见:
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;
我究竟做错了什么?
我想自定义边框颜色和宽度,所以我不能使用BevelKind = bkFlat
,加上bkFlat
RTL BidiMode 的“中断”,看起来真的很糟糕。