code for scroll wheel in winform demo

May 3, 2009 at 12:12 AM

Just a brief snippet to help out.

// MainForm
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(MainForm_MouseWheel);

void MainForm_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
        if (e.Delta > 0)
            if (trackBar1.Value != trackBar1.Maximum)
        else if (e.Delta < 0)
            if (trackBar1.Value > trackBar1.Minimum)
May 3, 2009 at 1:04 PM
done! thx
May 12, 2009 at 9:44 AM

Maybe something to implement in the core? And using a new property UseWheelMouse?

But I think this code is incomplete. In the trackbar ValueChanged I added the following two lines:

// Position the center at the cursor
RectLatLng area = MainMap.CurrentViewArea;
MainMap.CurrentPosition = new PointLatLng(area.Lat - area.HeightLat / 2, area.Lng + area.WidthLng / 2);

I like to implement ghchinoy suggestion, but want to change the CurrentPosition based on the mouse position. So you zoom in on the area the cursor points at. This is the same as clicking first and then zoom.

In the core I see the following code, but can't use it outside:

SetCurrentPositionOnly(e.X - Core.renderOffset.X, e.Y - Core.renderOffset.Y);

Is there a method that gets the LatLong from screen coordinates?


May 12, 2009 at 12:24 PM

yes, i use that technique in my own project too, just simply in OnMouseMove event use function public PointLatLng FromLocalToLatLng(int x, int y) and set position by public void SetCurrentPositionOnly(PointLatLng point) so when you zoom center position will be where mouse was before, additionaly i move mouse pointer to the center of the control(btw it needs native invoke stuff)

May 12, 2009 at 1:15 PM

Ok, thanks. That works.

I think it is best to do this only at zooming in.

Maybe something to implement in the core? And using a new property UseWheelMouse?

May 12, 2009 at 2:00 PM

something? ;}

May 12, 2009 at 2:12 PM

I don't get these smilies. Is there a translation list?

What I mean here: is it possible to implement a published property called UseWheelMouse in the core DLL? If it is true, the core will handle the zoom as described above.

May 12, 2009 at 2:18 PM


May 12, 2009 at 3:04 PM