DRAG AND DROP AYUDA!!!
Publicado por ana (45 intervenciones) el 17/02/2007 19:20:04
TENGO EL SIGUIENTE CODIGO PARA ARRASTRAR Y SOLTAR YA SEA UN PICTUREBOX O UN OBJETO IMAGE CONTENIDO EN UN FORMULARIO
'esto va en el modulo
Dim DY As Single
Dim DX As Single
'y de aqui en adelante el codigo
Private Sub CancelarDrag(Source As Control)
Source.Visible = True
Source.Drag vbCancel
End Sub
Private Sub FinalizarDrag(Source As Control, Button As Integer)
If Button = vbLeftButton Then
Source.Visible = True
Source.ZOrder
Source.Drag vbEndDrag
End If
End Sub
Private Sub IniciarDrag(Source As Control, Button As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
DX = X
DY = Y
'Permitir la operación de Drag & Drop
Source.Drag vbBeginDrag
'Cambiar a no visible, ya que si no, el form no detectaría que se ha soltado, si el puntero del ratón no sale del control.
Source.Visible = False
'Comienza el espectáculo
Source.Drag
End If
End Sub
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
'Si se quieren excluir algunos controles,
'hacer aquí la comparación.
Source.Visible = True
Source.Move X - DX - 60, Y - DY - 60
Source.Drag vbEndDrag
Source.ZOrder
End Sub
'
Private Sub image1_DragDrop(Source As Control, X As Single, Y As Single)
CancelarDrag Source
End Sub
'
Private Sub image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
IniciarDrag Image1, Button, X, Y
End Sub
'
Private Sub image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
FinalizarDrag Image1, Button
End Sub
EL PROBLEMA SE PRESENTA CUANDO QUIERO COLOCAR ESE CONTROL IMAGE O PICTURE DENTRO DE OTRO PICTUREBOX, YA QUE CUANDO LO ARRASTRO, O BIEN SE QDA EN EL MISMO SITIO O SE DESAPARECE, YA HE UTIIZADO TODOS LOS CODIGOS POSIBLES Y NINGUNO FUNCIONA... ES INDISPENSABLE HACERLO D ESTA MANERA, DE LO CONTRARIO TENDRIA Q BUSCAR UNA MANERA DE ARRASTRAR UNA LINEA DENTRO DE UN PICTUREBOX, SI ALGUIEN ME PUEDE AYUDAR CON ESTO SE LO AGRADECERIA
'esto va en el modulo
Dim DY As Single
Dim DX As Single
'y de aqui en adelante el codigo
Private Sub CancelarDrag(Source As Control)
Source.Visible = True
Source.Drag vbCancel
End Sub
Private Sub FinalizarDrag(Source As Control, Button As Integer)
If Button = vbLeftButton Then
Source.Visible = True
Source.ZOrder
Source.Drag vbEndDrag
End If
End Sub
Private Sub IniciarDrag(Source As Control, Button As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
DX = X
DY = Y
'Permitir la operación de Drag & Drop
Source.Drag vbBeginDrag
'Cambiar a no visible, ya que si no, el form no detectaría que se ha soltado, si el puntero del ratón no sale del control.
Source.Visible = False
'Comienza el espectáculo
Source.Drag
End If
End Sub
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
'Si se quieren excluir algunos controles,
'hacer aquí la comparación.
Source.Visible = True
Source.Move X - DX - 60, Y - DY - 60
Source.Drag vbEndDrag
Source.ZOrder
End Sub
'
Private Sub image1_DragDrop(Source As Control, X As Single, Y As Single)
CancelarDrag Source
End Sub
'
Private Sub image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
IniciarDrag Image1, Button, X, Y
End Sub
'
Private Sub image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
FinalizarDrag Image1, Button
End Sub
EL PROBLEMA SE PRESENTA CUANDO QUIERO COLOCAR ESE CONTROL IMAGE O PICTURE DENTRO DE OTRO PICTUREBOX, YA QUE CUANDO LO ARRASTRO, O BIEN SE QDA EN EL MISMO SITIO O SE DESAPARECE, YA HE UTIIZADO TODOS LOS CODIGOS POSIBLES Y NINGUNO FUNCIONA... ES INDISPENSABLE HACERLO D ESTA MANERA, DE LO CONTRARIO TENDRIA Q BUSCAR UNA MANERA DE ARRASTRAR UNA LINEA DENTRO DE UN PICTUREBOX, SI ALGUIEN ME PUEDE AYUDAR CON ESTO SE LO AGRADECERIA
Valora esta pregunta


0