How do I make a shape in a frame move when the mouse moves, but snaps to a grid. (every 32*32)
Thanks for any help, greatly appreciated :)
Printable View
How do I make a shape in a frame move when the mouse moves, but snaps to a grid. (every 32*32)
Thanks for any help, greatly appreciated :)
VB Code:
Private Sub Form_Load() Me.ScaleMode = vbPixels End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Me.Shape1.Left = (X \ 32) * 32 Me.Shape1.Top = (Y \ 32) * 32 End Sub
hmmm a bit different when moving inside a frame
VB Code:
Private Sub Frame1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Me.Shape2.Left = (((X / Screen.TwipsPerPixelX) \ 32) * 32) * Screen.TwipsPerPixelX Me.Shape2.Top = (((Y / Screen.TwipsPerPixelY) \ 32) * 32) * Screen.TwipsPerPixelY End Sub
the frames scalemode can not be sat to Pixels thus the screen.twipsperpixelX and Y
:)