Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

TppViewer and MouseWheel event

edited February 2004 in General
Hi,

I'm looking for an example or advice how to apply Mouse Wheel Event to
TppViewer component. I've tried

ppViewer.ScrollBox.OnMouseWheel := myMouseWheelEvent;

But no good luck. What's wrong?

Thanks in advance

Michael

Comments

  • edited March 2004
    Hi Michael,

    Below is some code one of our customers used to enable the mouse wheel at
    runtime for the report previewer. Hopefully this will help you get on the
    right track.

    unit AJBPreviewPlugIn;

    interface

    uses
    Messages, Controls, Classes, Types, ExtCtrls,
    ppPreview, ppTypes, Forms;

    type

    TAJBPreviewPlugIn = class(TppPreview)
    private
    protected
    public
    procedure BeforePreview; override;
    procedure MyMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta:
    Integer;
    MousePos: TPoint; var Handled: Boolean);

    end;

    TAJBCustomWheel = class(TControl)
    public
    property OnMouseWheel;
    end;

    implementation

    uses
    SysUtils, Dialogs, ppViewr;

    procedure TAJBPreviewPlugIn.BeforePreview;
    begin
    inherited BeforePreview;
    TAJBCustomWheel(Viewer.Owner).OnMouseWheel := MyMouseWheel;
    end;

    procedure TAJBPreviewPlugIn.MyMouseWheel(Sender: TObject; Shift:
    TShiftState;
    WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    var
    lScrollBar: TControlScrollBar;
    begin
    lscrollbar := Viewer.ScrollBox.VertScrollBar;
    lScrollBar.Position := lScrollBar.Position - (WheelDelta div 5);
    end;

    initialization
    TppPreviewPlugIn.Register(TAJBPreviewPlugIn);
    finalization
    TppPreviewPlugIn.UnRegister(TAJBPreviewPlugIn);
    end.


    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2004
    Thank you, Nico

    Michael

This discussion has been closed.