AngelicTech / thtmlviewer

Automatically exported from code.google.com/p/thtmlviewer
Other
1 stars 1 forks source link

Respond to Mouse Wheel without being focused #90

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have an AppMessage procedure that handles getting the WinControl under the 
mouse and sends any mouse scroll messages to the WinControl.  This works for 
all components except when a THTMLViewer control is under the mouse, it returns 
the TPaintPanel and no scrolling occurs.  You must activate the THTMLViewer 
component to use the scroll wheel which defeats the purpose.

Is there a way to direct the scroll message to the THTMLViewer component and 
have it scroll with the mouse wheel without the THTMLViewer component being 
focused?

This is my AppMessage procedure.

procedure TViewerForm.AppMessage(var Msg: TMsg; var Handled: Boolean);
var
  MousePos: TPoint;
  wc: TWinControl;
begin
  //mouse wheel scrolling for the control under the mouse
  if Msg.message = WM_MOUSEWHEEL then
    begin
      mousePos.X := Word(Msg.lParam);
      mousePos.Y := HiWord(Msg.lParam);
      wc := FindVCLWindow(mousePos);
      if wc = nil then
        Handled := True
      else
        if wc.Handle <> Msg.hwnd then
          begin
            SendMessage(wc.Handle, WM_MOUSEWHEEL, Msg.wParam, Msg.lParam);
            Handled := True;
          end;
    end;
end;

Original issue reported on code.google.com by scott.ca...@desktop-assistance.com on 21 Jul 2011 at 2:47

GoogleCodeExporter commented 9 years ago

Original comment by OrphanCat on 15 Dec 2011 at 3:30

GoogleCodeExporter commented 9 years ago
Issue 137 has been merged into this issue.

Original comment by OrphanCat on 2 Mar 2012 at 11:55

GoogleCodeExporter commented 9 years ago
You can use wc.Perform() to bypass the code that does not recognize the 
TPaintPanel correctly. This works well in TFrameViewer/TFrameBrowser, too:

procedure TViewerForm.AppMessage(var Msg: TMsg; var Handled: Boolean);
[...]
    wc := FindVCLWindow(mousePos);
    begin
      if wc is TPaintPanel then
        wc.Perform(CM_MOUSEWHEEL, Msg.WParam, Msg.LParam)
      else
        SendMessage(wc.Handle, WM_MOUSEWHEEL, Msg.wParam, Msg.lParam);
      Handled := True;
    end;
[...]

Original comment by OrphanCat on 26 Jan 2013 at 4:32

GoogleCodeExporter commented 9 years ago

Original comment by OrphanCat on 3 Feb 2013 at 3:21