英文:
Remove / Hide border of TTrackBar
问题
我在我的表单上有一个TTrackBar,但我希望它没有边框:
也就是说,只有蓝色箭头应该可见 - 边框(以及内容,即箭头导航的区域)应该是不可见的(如果需要,可以通过将颜色设置为clBtnFace来解决)。
我尝试了许多方法来隐藏它(在覆盖的Create构造函数中):
BevelEdges := [];
BevelInner := TBevelCut.bvNone;
BevelOuter := TBevelCut.bvNone;
BevelKind := TBevelKind.bkNone;
BorderWidth := 0;
Brush.Color := clBtnFace;
ParentCtl3D := FALSE;
Ctl3D := FALSE;
但似乎没有任何效果。
有办法实现我的目标吗?
英文:
I have a TTrackBar on my form, but would like it to not have the border around it:
ie. only the blue arrow should be visible - the border (and the content, ie the area that the arrow navigates in) should be invisible (could be solved by setting the color to clBtnFace if need be).
I have tried many things to hide this (in an overridden Create CONSTRUCTOR):
BevelEdges:=[];
BevelInner:=TBevelCut.bvNone;
BevelOuter:=TBevelCut.bvNone;
BevelKind:=TBevelKind.bkNone;
BorderWidth:=0;
Brush.Color:=clBtnFace;
ParentCtl3D:=FALSE;
Ctl3D:=FALSE;
but it doesn't appear to make any difference.
Is there a way to achieve my goal?
答案1
得分: 4
我相信你可以重写滑动条的CNNotify
消息方法来处理NM_CUSTOMDRAW
通知,当dwDrawStage = CDDS_ITEMPREPAINT
和dwItemSpec = TBCD_CHANNEL
时,将结果设置为CDRF_SKIPDEFAULT
:
procedure TTrackBar.CNNotify(var Message: TWMNotifyTRB);
begin
if
(Message.NMHdr.code = NM_CUSTOMDRAW)
and
(Message.NMCustomDraw.dwDrawStage = CDDS_ITEMPREPAINT)
and
(Message.NMCustomDraw.dwItemSpec = TBCD_CHANNEL)
then
Message.Result := CDRF_SKIPDEFAULT
else
inherited;
end;
不要忘记设置ShowSelRange = False
和TickStyle = tsNone
。
英文:
I believe you can override the track bar's CNNotify
message method to handle the NM_CUSTOMDRAW
notification when dwDrawStage = CDDS_ITEMPREPAINT
and dwItemSpec = TBCD_CHANNEL
, setting the result to CDRF_SKIPDEFAULT
:
procedure TTrackBar.CNNotify(var Message: TWMNotifyTRB);
begin
if
(Message.NMHdr.code = NM_CUSTOMDRAW)
and
(Message.NMCustomDraw.dwDrawStage = CDDS_ITEMPREPAINT)
and
(Message.NMCustomDraw.dwItemSpec = TBCD_CHANNEL)
then
Message.Result := CDRF_SKIPDEFAULT
else
inherited;
end;
Don't forget to set ShowSelRange = False
and TickStyle = tsNone
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论