1. DicomObjects.NET
  2. DicomObjects.COM
  3. When you have multiple DicomViewer on the Form

DicomObjects.NET

Unlike the COM version, in .NET version of DicomObjects the DicomViewer control’s MouseWheel event cannot be seen from the Event list on the properties panel. You have to do the coding yourself to hook the MouseWheel event.

Declare the event, somewhere at the startup of your program:

    dicomViewer1.MouseWheel += new MouseEventHandler(dicomViewer1_MouseWheel);

    void dicomViewer1_MouseWheel(object sender, MouseEventArgs e)
    {
      ' Whatever you like to do here with Delta
       MessageBox.Show(e.Delta.ToString());
    }

When you have multiple DicomViewer on the Form

You will need to explicitly set focus on the DicomViewer control which the mouse pointer has entered, to enable the MouseWheel event on that Viewer. The MouseEnter event is probably a good place to set the focus:

   
    private void Viewer1_MouseEnter(object sender, EventArgs e)
    {
        Viewer1.Focus();
    }

DicomObjects.COM

It is really simple to get DicomViewer’s MouseWheel event fired. First of all you need to set the DicomViewer’s UseMouseWheel property to true, as the default value is false. You can change this property either via the designer panel or in your code. Once you have changed it, create the DicomViewer’s MouseWheel event and put your code in there to handle mousewheel. It will fire every time you scroll the mouse.

Please note the Delta parameter is +120 if you scroll up the mousewheel and -120 if you scroll down. This gives you something to tell how the mousewheel was scrolled so that you can handle it properly.

 Private Sub DicomViewer1_MouseWheel(ByVal Shift As Long, ByVal Delta As Integer, 
                                     ByVal x As Long, ByVal y As Long)
   ' Delta is 120 if mousewheel scrolled UP once
   ' Delta is -120 if mousewheel scrolled DOWN once
   Label1.Caption = "Delta Value is: " & Delta & " X is: " & x & " Y is: " & y
 End Sub

One thing to note, the MouseWheel event will keep getting fired even when the mouse pointer is moved outside the Viewer’s display area. This is because the Viewer is still having the focus and thus active. This is a normal Windows behaviour and for a quick workaround, you can set DicomViewer’s UseMouseWheel property to false in DicomViewer’s Container (normally a DForm)’s MouseMove (Better if you have MouseEnter) event. And in the Viewer’s MouseMove event you set Viewer’s UseMouseWheel back to true. This will give you a result that MouseWheel only fires when you scroll within the viewer’s area.