Results 1 to 2 of 2

Thread: dragging objects off the form

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    2

    Post

    I'm making a checkers game and when I drag a peice off the board and drop it, it disappears. Is there a simple way to prevent this such as monitoring the mouse icon and when it changes to a NoDrop icon then I can replace that peice?

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    You could limit the Area in which the Cursor can move, eg.
    Code:
    Private Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End Type
    
    Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
    
    Private tRect As RECT
    
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        If Button = vbLeftButton Then
            tRect.Left = ScaleX(Left, vbTwips, vbPixels)
            tRect.Top = ScaleY(Top, vbTwips, vbPixels)
            tRect.Right = ScaleX(Left + Width, vbTwips, vbPixels)
            tRect.Bottom = ScaleY(Top + Height, vbTwips, vbPixels)
            Call ClipCursor(tRect)
        End If
    End Sub
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
        If Button = vbLeftButton Then Call ClipCursor(ByVal 0&)
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width