ListView 多选行为?

发布于 2024-10-06 12:56:24 字数 248 浏览 0 评论 0原文

Comtl32.dll v6.0 中的 ListView 执行多项选择(使用 Shift 键时)如下(x 表示已选择)

00xxxx
xxxxxx
xxxx00

ListView 的早期版本执行如下操作:

00xx00
00xx00
00xx00

有没有办法让它执行第一种方式(comctl32 v6.0)? 0路)?

谢谢约翰

The ListView in Comtl32.dll v6.0 does multiple selection (when using Shift key) as follows (x means selected)

00xxxx
xxxxxx
xxxx00

Earlier versions of ListView do it as follows :

00xx00
00xx00
00xx00

Is there any way to have it do the first way (the comctl32 v6.0 way)?

Thanks John

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

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

发布评论

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

评论(1

时光瘦了 2024-10-13 12:56:24

简短的回答是否定的。但是因为这似乎不完整...

ListView 没有公开允许您更改其选择行为的 API,正如 Hans 间接指出的那样在他的评论中,更改 6.0 版本之前的 comctl32.dll 版本中的 ListView 控件行为的唯一方法是使用时间机器。 ListView 控件中内置了许多与选择事件有关的独特行为,因此即使您尝试让所有者绘制控件来修改选择行为的外观,您会突然面临必须处理数量近乎荒谬的窗口消息的情况,这些消息可能会导致选择更改。

还值得指出的是,这个问题在完全不同的层面上被误导了。如果应用程序的用户运行的 Windows 版本包含 6.0 之前的 comctl32.dll 版本,这是他们期望 ListView 的行为控制。覆盖和更改它只会让他们感到困惑,因为它的工作方式与计算机上找到的所有其他 ListView 控件不同。相比之下,如果应用程序的用户运行的是包含 comctl32.dll v6 或更高版本的 Windows 版本,则 ListView 控件将已经按照您所描述的默认方式执行。 (并且您不应该出于完全相同的原因想要更改它。)

The short answer is no. But because that seems incomplete...

The ListView does not expose an API that allows you to change its selection behavior, and as Hans obliquely puts it in his comment, the only way to change the behavior of the ListView control found in versions of comctl32.dll prior to version 6.0 is with a time machine. There's a lot of unique behavior built into the ListView control regarding selection events, so even if you were to try and owner draw the control to modify the appearance of the selection behavior, you'd suddenly be faced with having to handle a nearly ridiculous number of window messages that could potentially cause a selection change.

It's also worth pointing out that this question is misguided on an entirely different level. If the user of your application is running a version of Windows that includes a version of comctl32.dll prior to version 6.0, this is the behavior that they expect out of the ListView control. Overriding and changing that would be nothing but confusing to them, because it wouldn't work the same way as every other ListView control found on their computer. By contrast, if the user of your application is running a version of Windows that includes comctl32.dll v6 or later, the ListView control will already perform as you describe by default. (And you shouldn't go wanting to change it for exactly the same reasons.)

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