In the FNCChat component, it appears that the OnMouseWheelUp and OnMouseWheelDown events do not fire when the "ChatWindow" have focus, the "ChatWindow" being the main part of the control where all the chat messages are shown.
The events DO fire if I click on the scrollbar and set focus on that, but not if I have the main window with all the messages.
I tried to use the OnVScroll event, but it only fires if the scrollbar is visible AND actually scrolls (which kinda makes sense), but it does not fire when the scrollbar have scrolled all the way to the top and i scroll upwards and that is excactly what I need - for automatically loading previous/older messages, or newer messages when i have scrolled all the way to the bottom and keeps on scrolling.
TTMSFNCChat has a Reload mechanism, but detecting upward scrolling when the scroll position is already at the top is not possible with the current implementation. We'll need to look at this as soon as time permits, I put this on our TODO list for now.
You indicated that you want to load older messages so just wanted to mention Reload in case you were not aware. It could potentially be used as a workaround solution. For example: the top chat message presented as a "load older messages" button and calling StartReload programmatically when it's clicked.
OnMouseWheelUp and OnMouseWheelUp are not rooted because the underlying TTMSFNCTreeView is using these events. OnVScroll doesn't trigger for scrolling upwards for a similar reason - it's implemented that way in TTMSFNCTreeView. Unfortunately there's no out of the box solution for now, we'll see what can be done when we have some time to allocate on this.
Could the underlying TreeView component not forward those events to the FNCChat ?
..or can I hook into them somehow ?
I may not have explained myself properly, but the loading of older messages comes from the backend chat-server, where (when the user reaches the top of the list of displayed items) the application requests additional messages and when there are no more "old" messages, the backend signals to the application that the beginning of the archive have been reached.
But, that is why I need to be able to hook into the mousewheel events.
How does the position parameter in OnVScroll work ?
I can see that when the control have scrolled all the way to the top, the position is 0, bot how do I determine when I have reached the bottom ?
Right now, I'm using the "Header" and "Footer" for "Click here to load older" or "Click here to load more", but it's not quite as elegant as I wish it were..
Apparently the TreeView.OnMouseWheel event does not appear to be exposed and even if I do a variant on it and hook into the OnMouseWheelUp and Down events, nothing happens..
This malfunction does not have anything to do with you having the TTMSFNCCustomControlBaseCommon.HandleMouseWheel event defined but left with no actual code in it, does it ?
I supposed too as well, but it did no difference at all, unfortunately..
However..
After at good bit of debugging and stepping patiently through what actually happens when a control handles a mousewheel event, it appears that by setting Handled := True at last line of TTMSFNCCustomTreeView.HandleMouseWheel, any further processing of the event down the foodchain is blocked (as it should be of course).
But, by changing this to "False", all other controls down the foodchain receives this event, until someone finally sets it to "True".
So, by setting Handled := False at line 5924 in VCL.TMSFNCCustomTreeView, i suddenly start to receive the OnMouseWheel, OnMouseWheelUp and OnMouseWheelDown in both the owner form and the FNCChat controls, then after doing "my thing" in the OnMouseWheelUp event in FNCChat I set Handled := True and everybody is happy.