有没有办法改变delphi 2010中的滚动条样式?

发布于 2024-11-26 03:08:20 字数 334 浏览 3 评论 0原文

我刚刚在构建 delphi 2010 应用程序时注意到滚动条在显示时始终具有相同的大小。无论实际需要滚动多少内容,条中间的滚动条始终具有相同的大小。相比之下,大多数现代应用程序使用滚动条,其中滚动条的大小与可滚动的量成正比,因此通过查看就可以清楚有多少内容可供滚动。有没有办法改变我的delphi控件上的滚动属性,或者需要自定义控件?

编辑: 此特定实例中的组件是 TDBGrid,它水平滚动。我没有意识到Windows正在绘制这些滚动条。也许沃伦是对的,但这个问题是无法回答的。比例滚动条在 Windows 上可能并不普遍,但我还没有在我的 Windows 机器上找到不使用它们的程序。甚至 Delphi 2010 IDE 也使用它们。

I just noticed while building a delphi 2010 application that the scrollbar is always the same size when it shows up. The scroller in the middle of the bar is always the same size no matter how much there actually is to scroll. In contrast, most modern applications use scrollbars where the size of the scroller is proportional to the amount available to scroll, so that by looking it is clear how much there is to scroll through. Is there a way to change the scroll properties on my delphi controls, or would that require custom controls?

edit:
The component in this particular instance was a TDBGrid, which scrolled horizontally. I didn't realize that windows was drawing these scrollbars. Perhaps Warren is correct and the question is unanswerable. Proportional scrollbars may not be ubiquitous on windows but I have yet to find a program on my windows machine that doesn't use them. Even the delphi 2010 IDE uses them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪都笑了 2024-12-03 03:08:20

这就是我在我的自定义组件(一个简单的文本查看器)中执行此操作的方法:

procedure TCustomViewer.UpdateScrollInfo;
var
  ScrollInfo: TScrollInfo;
begin
  with ScrollInfo do
  begin
    cbSize := SizeOf(ScrollInfo);
    fMask := SIF_POS or SIF_PAGE or SIF_RANGE or SIF_DISABLENOSCROLL;
    nMin := 0;
    nMax := 1023;
    nPage := PageWidth;
    nPos := FTopLeft.X;
  end;
  SetScrollInfo(Handle, SB_HORZ, ScrollInfo, True);
  with ScrollInfo do
  begin
    nMax := FLines.Count - 1;
    nPage := PageHeight;
    nPos := FTopLeft.Y;
  end;
  SetScrollInfo(Handle, SB_VERT, ScrollInfo, True);
  UpdateCaretPos;
  Update;
end;

IOW,您使用 TScrollInfo,用您需要更改的值填充它,包括 nMax< /code> 和 nPage,并用它调用 SetScrollInfo,指示要更改的滚动条。我确信大多数带有滚动条的控件都会在内部控制它们,但如果控件没有,您可以尝试 SetScrollInfo。这可能对其中一些人有用。 TScrollInfoSetScrollInfoWindows.pas 中定义。这是MSDN 链接

This is how I do it in a custom component of mine (a simple text viewer):

procedure TCustomViewer.UpdateScrollInfo;
var
  ScrollInfo: TScrollInfo;
begin
  with ScrollInfo do
  begin
    cbSize := SizeOf(ScrollInfo);
    fMask := SIF_POS or SIF_PAGE or SIF_RANGE or SIF_DISABLENOSCROLL;
    nMin := 0;
    nMax := 1023;
    nPage := PageWidth;
    nPos := FTopLeft.X;
  end;
  SetScrollInfo(Handle, SB_HORZ, ScrollInfo, True);
  with ScrollInfo do
  begin
    nMax := FLines.Count - 1;
    nPage := PageHeight;
    nPos := FTopLeft.Y;
  end;
  SetScrollInfo(Handle, SB_VERT, ScrollInfo, True);
  UpdateCaretPos;
  Update;
end;

IOW, you use a TScrollInfo, fill it up with the values you need to change, including nMax and nPage, and call SetScrollInfo with it, indicating the scroll bar you want to change. I'm sure that most controls with scroll bars control them internally, but if a control doesn't, you could try SetScrollInfo. It might work for some of them. TScrollInfo and SetScrollInfo are defined in Windows.pas. Here is the MSDN link.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文