Code for the drag-and-drop Email demo
Click here to download a zip file of the form, project and icon files
Dim NextLetter As Integer
Private Sub btnEmpty_Click()
imgMailbox.Picture = imgMboxEmpty.Picture
End Sub
Private Sub btnNew_Click()
Load imgLetter(NextLetter)
' imgLetter is a control array, so LOAD creates a
' new control and gives it the INDEX specified
' by NextLetter
' next, we give the new member of the control array
' a location in the window, and make it visible
imgLetter(NextLetter).Left = btnNew.Left - 2000 + NextLetter * 100
imgLetter(NextLetter).Top = btnNew.Top
imgLetter(NextLetter).Visible = True
' increment NextLetter so that a subsequent Click will create a new letter
NextLetter = NextLetter + 1
End Sub
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Source.Move X, Y
' moves control to where user specifies
End Sub
Private Sub Form_Load()
' Initialize the Mailbox icon and the NextLetter variable
imgMailbox.Picture = imgMboxEmpty.Picture
NextLetter = 1
End Sub
Private Sub imgMailbox_DragDrop(Source As Control, X As Single, Y As Single)
'
' the mailbox requires its own drag-and-drop procedure.
' When a control is dropped on the mailbox, the program checks
' the tag of the source object. If the source object is not a
' letter, the procedure exits, and the source object is not moved.
' Otherwise, the UNLOAD statement removes the letter, and the
' picture property of the mailbox is set to the icon of imMboxFull
If Source.Tag <> "Letter" Then
Beep
Exit Sub
End If
Unload Source
imgMailbox.Picture = imgMboxFull.Picture
End Sub
Last Updated by BD on 02/18/09