Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDrag and drop onto ActiveX controls
KeywordsActiveX control, drag and drop
CategoriesActiveX Controls, ActiveX, Controls
 
Start the drag in a control's MouseDown event. This example lets you drag a PictureBox or Label onto an ActiveX control.
 
Private Sub Picture1_MouseDown(Index As Integer, Button As _
    Integer, Shift As Integer, X As Single, Y As Single)
    Picture1(Index).Drag
End Sub

Private Sub Label1_MouseDown(Index As Integer, Button As _
    Integer, Shift As Integer, X As Single, Y As Single)
    Label1(Index).Drag
End Sub
 
In the ActiveX control's DragOver event, provide feedback. This example highlights the control if the drag source is a PictureBox or Label.
 
Private Sub Dropper1_DragOver(Index As Integer, Source As _
    Control, X As Single, Y As Single, State As Integer)
    If State = vbEnter Then
        If (TypeOf Source Is PictureBox) Or _
           (TypeOf Source Is Label) _
        Then
            Dropper1(Index).Highlight
        End If
    ElseIf State = vbLeave Then
        Dropper1(Index).Unhighlight
    End If
End Sub
 
Finish the drop in the DragDrop event.
 
Private Sub Dropper1_DragDrop(Index As Integer, Source As _
    Control, X As Single, Y As Single)
    Dropper1(Index).Unhighlight

    If (TypeOf Source Is PictureBox) Then
        Set Dropper1(Index).Picture = Source.Picture
    ElseIf (TypeOf Source Is Label) Then
        Dropper1(Index).Caption = Source.Caption
    End If
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated