自定义Windows窗体滚动条 [英] Customize Windows Form Scrollbar

查看:208
本文介绍了自定义Windows窗体滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有搜索万维网没有正确的答案。

I have searched the world wide web without a proper answer.

在我的Windows窗体应用程序,我想改变这种状况属于FlowLayoutPanel的滚动条的宽度。

In my Windows Form application, i want to change the width of a scrollbar that belongs to a FlowLayoutPanel.

滚动条增加了自动,因为流布局面板的量较大的表。

The Scrollbar is added "automatically" since the content of the Flow Layout Panel is larger the Form.

这是我在网络上找到,这似乎是棘手的。

From what I've found on the web, it seems to be tricky.

有没有什么解决办法?

干杯!

推荐答案

没有,有没有办法改变单一控制(显示在滚动条的宽度虽然有一个全系统的设置这将影响到的所有的所有应用程序中的滚动条)。

No, there's no way to change the width of a scrollbar displayed on a single control (although there is a system-wide setting that will affect all scrollbars in all applications).

丑恶的真相是,低滚动条控制是远远比它看起来更为复杂。基本上,在滚动条的 FlowLayoutPanel的是由Windows本身(而不是在.NET Framework)中抽取因为 WS_HSCROLL 和/或 WS_VSCROLL ,这对于幕后的控制设置窗口样式。该 FlowLayoutPanel的不提供任何设施,以改变或修改了这些内置的滚动条绘制。在不同的WinForms等更先进的修改,还有我们可以发送到控件的窗口过程没有这样的消息。而更糟糕的是,在滚动条绘制的非客户区的 FlowLayoutPanel的,这意味着我们不能只覆盖了涂料事件和处理绘制的滚动条自己。

The ugly truth is that the lowly scrollbar control is far more complicated than it looks. Basically, the scrollbars on the FlowLayoutPanel are drawn by Windows itself (rather than the .NET Framework) because of the WS_HSCROLL and/or WS_VSCROLL window styles that are set for the control behind the scenes. The FlowLayoutPanel doesn't provide any facility to change or modify how these built-in scrollbars are drawn. Unlike other more advanced modifications in WinForms, there are no such messages we can send to the control's window procedure. And to make matters worse, the scrollbars are drawn in the non-client area of the FlowLayoutPanel, which means we can't just override its Paint event and handle drawing the scrollbars ourselves.

不幸的是,如果你真的想自定义您的滚动条,你将不得不隐藏内置的滚动条和滚动您自己。这不是很困难,因为它的声音,虽然,如果你为它。 这在$ C $的CProject文章提供了有关创建自己的换肤滚动条好走通作为一个用户控件,并用它来取代在您选择的容器控件。

Unfortunately, if you really want to customize your scrollbars, you're going to have to hide the built-in scrollbars and roll your own. It's not quite as difficult as it sounds, though, if you're up for it. This article on CodeProject provides a good walk-through on creating your own skinnable scrollbar as a user control and use it as a replacement in the container control of your choice.

这篇关于自定义Windows窗体滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆