VirtualTreeView 不随鼠标滚轮滚动

huangapple go评论54阅读模式
英文:

VirtualTreeView is not scrolling with mouse wheel

问题

我有一个用许多节点填充的TVirtualStringTree,垂直滚动条可见。然而,尝试使用鼠标滚轮滚动时没有任何反应。是否需要启用某个设置,或者该控件默认不支持鼠标滚轮滚动(即在事件处理程序中不需要编写任何额外的代码)?

英文:

Using: Delphi 10.2.3 Tokyo, VCL Forms application, Windows 10 Pro, latest TVirtualStringTree

I have a TVirtualStringTree populated with many nodes, and the vertical scroll bar is visible. However, nothing happens when trying to scroll with the mouse wheel. Is there any setting that needs to be enabled, or does the control not support mouse wheel scrolling by default (ie. without writing any additional code in an event handler)?

答案1

得分: 0

这个组件没有专门的设置。只是你的VirtualTreeView组件没有接收到鼠标滚轮的Windows事件。

我曾经遇到相同的问题,在我的情况下,底层的窗体/窗口有一个TApplicationEvents,它首先获取了所有的Windows消息(即使一个新的带有我的VT组件的窗体出现在上面),并将Handled设置为true。

在TApplicationEvents的OnMessage函数中,我进行了如下封装...

if ((MyVTForm == NULL) || !MyVTForm->Visible) {
    ...
}

...现在它可以工作了(抱歉,这是C++ Builder的代码)。

英文:

There is no special setting in this component for that. It's just that your VirtualTreeView component doesn't get the MouseScroll Windows events.

I had the same problem and in my case the underlying form/window has had an TApplicationEvents which got all Windows messages first (even if a new form with my VT component comes above) and set Handled = true.

Within the OnMessage function of this TapplicationEvents I wrapped ...

if ( ( MyVTForm == NULL ) || !MyVTForm->Visible ) {
...
}

... around and it works now (sorry, C++ Builder code).

huangapple
  • 本文由 发表于 2023年2月26日 19:40:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/75571725.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定