I'm trying to zoom in on a Picturebox when scrolling the mousewheel, the code below zooms in on the image only to the center of the image, not at the current cursor position. How would I fix this?

PictureBox1.Size = New System.Drawing.Size(PictureBox1.Width + e.Delta / 1, PictureBox1.Height + e.Delta / 1)
PictureBox1.Location = New Point(Control.MousePosition.X - PictureBox1.Width / 2, Control.MousePosition.Y - PictureBox1.Height / 2)

As is typical with sample code/controls like the one referenced in the previous post, it is written in an older version of Visual Studio. Loading it into Visual Studio 2010 (which is what I am using) results in nothing usable. There are also no instructions on how to rebuild the demo project. Trying to rebuild in even newer versions (2012, 2013) is likely to lead to nothing but frustration.

Yes I agree that this will

lead to nothing but frustration

I tried to run this program, but couldn't extract any foundation where to start from.

My bad. Thought it would be easier to change the code. I use vb 13 express and no you just can't expect to import and run the code - it needs to get modified. I will give it aa try.

I found this code but I wasn't able to make it work in my program.

Inherits PictureBox

 Overloads Property Image() As Image ' we want to hook when client's set the image to reset the zoom level to unzoomed
        Get
            Return MyBase.Image
        End Get
        Set(ByVal value As Image)
            zmLevel = 1 ' reinit
            MyBase.Image = value
        End Set
    End Property

The code above wouldn't compile properly, and I'm not sure how to fix the issue. Tried to make research, but no success on finding any good examples of code.

I was able to convert the lib to vb 2010 and build it. Try taking the attached dll and dropping it on the toolbox in visual studio. I've used it in a couple of projects and it works just fine. It has the same properties/methods as a picturebox with a few extras.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.