3

I am using Lazarus with THTMLPort to render some html code in my program. The OnMouseEvent for the HTMLViewer window is not firing on the mouse scrolling. I have found a problem like this in a similar, but not the same, project for Delphi, called THTMLViewer. At this page for that project the devel posts changes in the code of the htmlviewer.pas unit to enable the OnMouseWheel event to fire. I tried to make those changes to the code in the corresponding htmlviewer.pas unit for THTMLPort, but it wouldn't work. (As a side note, I have tried simply using THTMLViewer for my program instead, but since it is still in development for use in Lazarus, it would not work). Here is the only code in the unit that mentions the mousewheel, esp. the OnMouseWheel event:

{$ifdef ver120_plus}
property OnMouseWheel;
{$endif}

...

{----------------ThtmlViewer.HTMLMouseWheel}
{$ifdef ver120_plus}
procedure ThtmlViewer.HTMLMouseWheel(Sender: TObject; Shift: TShiftState;
  WheelDelta: Integer; MousePos: TPoint);
var
  Lines: integer;
begin
Lines := Mouse.WheelScrollLines;
if Lines > 0 then
  if WheelDelta > 0 then
    VScrollBarPosition := VScrollBarPosition - (Lines * 16)
  else
    VScrollBarPosition := VScrollBarPosition + (Lines * 16)
else VScrollBarPosition := VScrollBarPosition - WheelDelta div 2;
end;

function ThtmlViewer.DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;
                                         MousePos: TPoint): Boolean;
begin
result:= inherited DoMouseWheel(shift, wheelDelta, mousePos);
if not result and not (htNoWheelMouse in htOptions) then
  begin
  HTMLMouseWheel(Self, Shift, WheelDelta, MousePos);
  Result := True;
  end;
end;
{$endif}

So, can anyone assist in getting THTMLPort OnMouseWheel event working? I am sort of new to Lazarus, so I can't find my way around perfectly just yet. Thanks for any help.

preahkumpii
  • 1,301
  • 4
  • 21
  • 36
  • I don't know if this is the right place to help with broader problems on unstable code. Additionally the above code isn't compatible with the philosophy of the Lazarus lcl. THtmlViewer should provide properties to attach scrollbars. The mouse wheel events would then be handled through the scrollbar(s). – Kitana Dec 06 '14 at 13:39

0 Answers0