Results 1 to 3 of 3

Thread: [RESOLVED] Dragging and dropping..

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2006
    Posts
    221

    Resolved [RESOLVED] Dragging and dropping..

    Would it be possible to have it so there could be a picture on your form, you drag and drop it somewhere else and the original picture stays there but a new one which is identical appears in the place you dropped it and you could do it again to create a third one and then do it over and over again?

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Dragging and dropping..

    You can do it by creating a control array of the PictureBox
    Try this:
    VB Code:
    1. Option Explicit
    2. '[b] Add a picturebox in the form and set its Index = 0[/b]
    3. Private Const WM_NCLBUTTONDOWN = &HA1
    4. Private Const HTCAPTION = 2
    5.  
    6. Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    7. Private Declare Function ReleaseCapture Lib "user32" () As Long
    8.  
    9. Private Sub Picture1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    10.     If Button = vbLeftButton Then
    11.         If Index = 0 Then
    12.             Load Picture1(Picture1.UBound + 1)
    13.             Picture1(Picture1.UBound).Visible = True
    14.             Picture1(Picture1.UBound).ZOrder 0
    15.             '
    16.             ReleaseCapture
    17.             SendMessageLong Picture1(Picture1.UBound).hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
    18.         End If
    19.     End If
    20. End Sub
    (Modification of this code)
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3
    Junior Member
    Join Date
    Jun 2006
    Posts
    18

    Re: Dragging and dropping..

    sure u can.

    'add a picture box named picture1 and set index=0
    Option Explicit
    Dim picCount As Integer
    Dim dx As Single, dy As Single

    Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
    Load Picture1(picCount + 1)
    Picture1(picCount + 1).Left = X - dx
    Picture1(picCount + 1).Top = Y - dy
    Picture1(picCount + 1).Visible = True
    picCount = picCount + 1
    End Sub

    Private Sub Picture1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    dx = X
    dy = Y
    End Sub

    hope this code helps. ^^

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