I am using the PDFViewer Demo trying to understand why scrolling of an unfocused ImageEnView component. I have added a fileListbox and a wwdbGrid to the form.
I run the program and load a PDF then check the 'Show all Pages' check box.
Then, if I click on the FileListBox and move the mouse over ImageEnview it scrolls very nicely. When I click on the wwDBGrid and move the mouse over the ImageEnView it will not scroll. Clicking on the ImageEnView does implement scrolling of course, but hoping to not have to do that.
Yes, it happens if I use a TStringGrid. One other caveat is that I am using the on Delphi2007 at the moment. Have tried this behavior on anything more current yet.
Sorry, I don't see that in Delphi 12. I expect the "Focused" TStringList is swallowing the mouse wheel calls. Presumably it was an issue that have been fixed by Embarcadero.
Since something is stealing the Mousewheel scroll from the ImageEnView do you have a suggestion on how I can scroll with code. I have tried attempts with ImageEnView1.Perform on ImageEnView1MouseWheel but that seems to just want to move the entire page so far.
I fired up Delphi 2007. As expected the mouse wheel calls are being swallowed by TStringList if it is the active control (even though it isn't under the cursor).
Also, as expected, I'm not seeing ImageEnView1MouseWheel events in this situation. This means that there is no workaround while TStringList has focus. So your only solution is to give focus to the ImageEnView:
So even when ImageEnView has focus it won't scroll with the MouseWheel. The OnMouseWheel is firing so I could move it with code but I can't narrow down the correct way to do that. Or even if some other component has focus I could intercept and scroll the PDF.
Any suggestions? I've tried ImnageEnView.ScrollBy but that doesn't seem to do much. I've tried Perform. That moves it but is not predictable for me. PDFViewer has a few things but mostly seem to just moving to a new page.
We seem to be seeing different things. You are seeing TImageEnView.OnMouseWheel events, whereas I do not. If TImageEnView.OnMouseWheel is occurring then the internal scrolling code should also occur. So I cannot understand what is occuring.
I cannot create a situation where TImageEnView has focus and scrolling does not occur.
You might want to try putting a breakpoint in the TImageEnView.DoWMMouseWheel method (I would expect it does not fire in this situation).
If your OnMouseWheel does fire you could try explicitly performing the scroll, which would be something like:
nPos := ImageEnView1.ViewY + Direction * ImageEnView1.MouseWheelParams.Value;
ImageEnView1.ViewY := nPos;
ImageEnView1.PdfViewer.SetPageToScrollPos( Direction >= 0 );
Thanks for the code but... The 'Direction' variable coding was not shown. But changing the first lines fixed it for me. I did this:
Direction := WheelDelta div 100; // maybe just needed + or - 1 nPos := ImageEnView1.ViewY - Direction * ImageEnView1.MouseWheelParams.Value;
As far as weird behavior I am using other third party tools on this form. The stringgrid mocked part of the problem but not all. So I assume something else is chewing it up.