TListView滚动事件
TListView 控件是否有一个在控件滚动时触发的事件?
我不想对 TListView 控件进行子类化。
Does the TListView control have an event that will fire whenever the control is scrolled?
I would prefer not to have to sub-class the TListView control.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这工作得很好,但可能违反你的问题的限制。
在包含使用
TListView
的表单的单元的interface
部分(在TForm
声明之前),添加Then, 在
同一单元的 >implementation
部分,定义This works perfectly, but might violate the constraints of your question.
In the
interface
section of the unit containing the form that use theTListView
(prior to theTForm
declaration), addThen, in the
implementation
section of the same unit, define您可以对窗口进行子类化,而无需编写后代类,这在您期望更改的行为是一次性需求时非常有用。编写一个
TWndMethod
函数,如 Andreas的答案,但是将其写在您想要的任何类中,例如拥有列表视图的表单。将其分配给列表视图控件的WindowProc
财产。在执行此操作之前,请存储该属性的先前值,以便您可以将所有其他消息推迟到它。You can subclass a window without writing a descendant class, which is useful when you expect the changed behavior to be a one-off requirement. Write a
TWndMethod
function like in Andreas's answer, but write it in whatever class you want, such as the form that owns the list view. Assign it to the list-view control'sWindowProc
property. Before you do that, store the property's previous value so you can defer all other messages to it.或者,如果您只想捕获垂直滚动事件,您可以使用它。代码与 Andreas 发布的几乎相同......
Or if you want to trap just vertical scroll event, you can use this. Code is almost the same as Andreas posted ...
所有答案都很好:-),但我不想创建新的班级孩子。 感谢大家的帮助:-)!
我的解决方案:我使用组件(在 Delphi 7 中)ApplicationEvents 并检查 的更改滚动条位置(GetScrollPos(ListView.Handle, SB_VERT))。
The all answer is fine :-), but I don't wont to create new child of class. Thanks everyone for your help :-)!
My resolution: I use component (in Delphi 7) ApplicationEvents and I check change of ScrollBar position (GetScrollPos(ListView.Handle, SB_VERT)).