View Single Post
 
Old 01-08-2017, 12:24 PM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 289
Default outline moves but not picture box

Thought I'd posted this earlier today, but it seems not! OK, I am rewriting parts of a previous app for which the following code was recommended. All I want to do is allow the user (i.e.,me) to drag a picture box across the screen. Nothing else, nothing special - just a simple 'conventional' move with the mouse down so that when the mouse button is released the picture box (with loaded picture) is somewhere else.
Code:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Static lx As Single, ly As Single
  If Button = vbLeftButton Then 'or vbRightButton
    Picture1.Left = Picture1.Left + (X - lx)
    Picture1.Top = Picture1.Top + (Y - ly)
  Else
    lx = X: ly = Y
  End If
End Sub
...which worked on that occasion, for which thanks. But now what happens is that the outline moves but not the picture! So, what am I missing? Do I need to change some properties of the picture box, and/or write more code for various mouse procedures? I note in the above code the variables lx and ly are given no values, so they will both be zero.
Reply With Quote