All code samples

Override MouseWheel event

This code sample helps to override MouseWheel event. The default behavior of the the mouse wheel is to scroll. To override this default behavior, you must introduce a new class that inherits from StandardPagesViewer and override the OnMouseWheel method like this: following code shows how to override this default our.

public class MyPagesViewer : TallComponents.Interaction.WinForms.Controls.StandardPagesViewer
{
  protected override void OnMouseWheel(MouseEventArgs e)
  {
    // custom action such as zooming here

    ((HandledMouseEventArgs)e).Handled = true;
  }
}

Inside the InitializeComponent of your MainForm, make sure that you instantiate this new class like this:

public class MainForm : System.Windows.Forms.Form
{
  #region Windows Form Designer generated code

  private void InitializeComponent()
  {
    ...
    this.pagesViewer = new TallComponents.PDF.ReaderControls.MyPagesViewer();
    ...
  }
}

Relevant products