How to get mouse 's coordinate in menu click

smiles

Well-known member
Joined
May 21, 2008
Messages
47
Programming Experience
Beginner
VB.NET:
    Private Sub ZoomInToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ZoomInToolStripMenuItem.Click
        PictureBox1.Width = CInt(PictureBox1.Width * 1.25)
        PictureBox1.Height = CInt(PictureBox1.Height * 1.25)
        PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
    End Sub
Suppose that I want to get the mouse coordinate in the function above for another purpose, how can I do it ?
Thanks !!!
 
Mouse coordinates are always available from the system shared Cursor.Position. All controls has also a PointToClient method in case you need to convert the screen values relative to a clients.
 
zoom window

Thanks !!!
I want to use it for position of panel's scrollbars when zooming pictureBox, normally, when zooming, the direction is upper left of the panel, now I want the direction is toward to the position of my mouse when click menu zoom in
VB.NET:
    Private Sub ZoomInToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ZoomInToolStripMenuItem.Click
        PictureBox1.Width = CInt(PictureBox1.Width * 1.25)
        PictureBox1.Height = CInt(PictureBox1.Height * 1.25)
        PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
        Panel1.AutoScrollPosition = New Point(Cursor.Position.X * 1.25, Cursor.Position.Y * 1.25)
    End Sub
It is better (still get error in position of scroll bar when times of zooming increase) but not smooth, do you think of any better way ?
Thanks !!!
 
Back
Top