|
-
Aug 11th, 2012, 04:40 PM
#1
Thread Starter
New Member
Draw Image On PictureBox At Mouse Position
Hi! It seems I have ran into a small problem. How can you draw an image to a picturebox at the mouse's pointer location. If image can be centered there, that would be
great! Thanks for any help!
-
Aug 11th, 2012, 05:10 PM
#2
Re: Draw Image On PictureBox At Mouse Position
Er ... that doesn't really make sense. What exactly are you trying to do?
-
Aug 11th, 2012, 05:18 PM
#3
Thread Starter
New Member
Re: Draw Image On PictureBox At Mouse Position
I am trying to draw an image on top of the background at a certain location. Is this possible with a picturebox, or do I need another control?
-
Aug 11th, 2012, 05:59 PM
#4
Re: Draw Image On PictureBox At Mouse Position
You'll need to decide where to put the various bits of this but this is the basic code you need.
vb.net Code:
Dim pic As Bitmap = New Bitmap("filename")
Dim g As Graphics = Graphics.FromHwnd(PictureBox1.Handle)
g.DrawImage(pic, New Rectangle(sender.PointToClient(MousePosition).X - pic.Width / 2, sender.PointToClient(MousePosition).Y - pic.Height / 2, pic.Width, pic.Height))
-
Aug 11th, 2012, 06:09 PM
#5
Thread Starter
New Member
Re: Draw Image On PictureBox At Mouse Position
Thanks a ton!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|