Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15136

[RESOLVED] Stupid Drag Drop question

$
0
0
I can drag a command button anywhere on a form, but I canNOT seem to be able to drag a command button on top of another command button.

I have an array of 4 command buttons (btnPlayer). I have an array of 27 command buttons (command2).

Code:

Dim iGrabX As Integer
Dim iGrabY As Integer
Dim ControlZOrder As Long


Private Sub btnPlayer_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
    Source.Move btnPlayer(Index).Left + X - iGrabX, btnPlayer(Index).Top + Y - iGrabY
End Sub


Private Sub btnPlayer_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbLeftButton Then
        iGrabX = X
        iGrabY = Y
        btnPlayer(Index).Drag vbBeginDrag
    Else
        ControlZOrder = btnPlayer(Index).hWnd
    End If
End Sub


Private Sub btnPlayer_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbLeftButton Then
        btnPlayer.Drag vbEndDrag
    End If
End Sub

Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
    Source.Move X - iGrabX, Y - iGrabY
End Sub

Private Sub Command2_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
    Source.Move X - iGrabX, Y - iGrabY
End Sub

I would like to drop any one of those 4 buttons (btnPlayer) in the center (vertically and horizontally) of any of the target buttons (command2)

Viewing all articles
Browse latest Browse all 15136

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>