OnMouseWheel没有在Lazarus中使用THTMLPort组件触发

时间:2012-08-24 10:03:33

标签: delphi pascal lazarus

我正在使用Lazarus和THTMLPort在我的程序中呈现一些HTML代码。 HTMLViewer窗口的OnMouseEvent在鼠标滚动时不会触发。我在类似但不一样的Delphi项目中发现了这样的问题,称为THTMLViewer。在该项目的this page处,devel会在htmlviewer.pas单元的代码中发布更改,以启用OnMouseWheel事件。我尝试对THTMLPort的相应htmlviewer.pas单元中的代码进行这些更改,但它不起作用。 (作为旁注,我已经尝试过简单地使用THTMLViewer代替我的程序,但由于它仍在开发中用于Lazarus,它不起作用)。这是该单元中唯一提到鼠标滚轮的代码,尤其是OnMouseWheel事件:

{$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}

那么,任何人都可以协助让THTMLPort OnMouseWheel事件发挥作用吗?我对Lazarus来说有点新鲜,所以我还是找不到完美的方法。谢谢你的帮助。

0 个答案:

没有答案