Click here to Skip to main content
15,886,728 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi All

Developing an windows form application vb, Busy dragging an image bitmap from another control, want to drop this image at the mouse position on the picturebox. The error which i have is that when i drag over the picturebox with the mouse down left button none of the
Handles PBx.MouseMove
are functional.
I have set focus to the Picturebox control ,
Handles PBx.DragEnter
are functional, any ideas on how to bypass the picturebox "locked state" as the left mouse button down when entering the control.
i may have the incorrect mythology in doing this so any assistance appreciated.

Regards
Richard

What I have tried:

Have Searched Google and review some other example apps but others just insert the image into the control as a new image from the Dragged bitmap.
Posted
Updated 20-Aug-20 5:43am
Comments
[no name] 18-Aug-20 16:53pm    
Try "MouseEnter" ... can't tell whether your "drag and drop" context is valid. You seem to expect certain behavior.
Grid-Code 19-Aug-20 4:58am    
Hi Gerry Schmitz

Private Sub PBx_DragOver(sender As Object, e As DragEventArgs) Handles PBx.DragOver
PBx_ImgIns = New Point(CInt((CSng(Me.PBx.Image.Width) / Me.PBx.Width) * e.X), CInt((CSng(Me.PBx.Image.Height) / Me.PBx.Height) * e.Y))
Console.WriteLine("x : " & PBx_ImgIns.x & " y : " & PBx_ImgIns.y)
End Sub

The above gives e.X & e.Y , but incorrect what i had read up on is that e = Screen Point Location - and not the PBx(PictureBox) Even though PBx.DragOver e not related to PBx Control?
** Trying too get the image pixel point - mouse position
Thanks for the Tip above
Cheers Richard

1 solution

Private Sub PBx_DragOver(sender As Object, e As DragEventArgs) Handles PBx.DragOver
       'PBx_ImgIns = Image Point
       'PBx = Picturebox Control
       Dim PBxPnt As Point = PBx.PointToClient(New Point(e.X, e.Y)) 'e.Y & e.X = Screen Point
       PBx_ImgIns = New Point(CInt((CSng(Me.PBx.Image.Width) / Me.PBx.Width) * PBxPnt.X), CInt((CSng(Me.PBx.Image.Height) / Me.PBx.Height) * PBxPnt.Y))
   End Sub


If anyone interested code example above gives picturebox control point, then the Picturebox image point, this should work for dropping an object at mouse location on a control
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900