Results 1 to 3 of 3

Thread: OLE Drag & Drop - Is this possible?

  1. #1

    Thread Starter
    Fanatic Member The_Grudge's Avatar
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    836

    OLE Drag & Drop - Is this possible?

    I've got a listbox and some textboxes.

    The user drags people's names from the listbox to the one of the empty textboxes.

    Right now when you drag a name out of the listbox you see the standard VB/Windows mouse icons for drag & drop.

    Is there a way I can make the mouse icon appear as the name they are dragging??

    For example, if I were to click on the name "Willy Wonka" in the listbox, could I make it so that the text comes out of the listbox and is moved around with the mouse button.
    Basically, instead of seeing mouse icons they'd see the regular mouse arrow and then just under it they'd see the text "Willy Wonka".

  2. #2

    Thread Starter
    Fanatic Member The_Grudge's Avatar
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    836

    Talking Re: OLE Drag & Drop - Is this possible?

    Anyone??

    Bueller....bueller......?

  3. #3
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: OLE Drag & Drop - Is this possible?

    You could try something like this code which uses two text boxes. One the user drags from, the other acts as drag icon.
    Place the code in a form
    VB Code:
    1. Option Explicit
    2. Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    3.  
    4. Private Declare Function ReleaseCapture Lib "user32" () As Long
    5.  
    6. Dim IsCaptured As Boolean
    7.  
    8. Private Sub StartCapture(hwnd As Long)
    9.     With Text1
    10.         .Left = Text2.Left
    11.         .Top = Text2.Top
    12.         .Width = Text2.Width
    13.         .Height = Text2.Height
    14.         '.BackStyle = 0
    15.         .ZOrder 0
    16.         .Text = Text2.Text
    17.         .Visible = True
    18.     End With
    19.     Me.MousePointer = vbArrow
    20.     SetCapture Me.hwnd
    21.     IsCaptured = True
    22. End Sub
    23.  
    24. Private Sub StopCapture()
    25.         ReleaseCapture
    26.         IsCaptured = False
    27.         Text1.Visible = False
    28. End Sub
    29.  
    30. Private Sub Form_Load()
    31.     With Text1
    32.         .Visible = False
    33.         .ForeColor = &H80000003
    34.         .BackColor = &H80000004
    35.         .Appearance = 0
    36.     End With
    37.    
    38. End Sub
    39.  
    40. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    41.     If IsCaptured Then
    42.         With Text1
    43.             .Top = Y
    44.             .Left = X
    45.         End With
    46.     End If
    47. End Sub
    48.  
    49. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    50.     If Button = 1 And IsCaptured Then
    51.         StopCapture
    52.     End If
    53. End Sub
    54.  
    55. Private Sub Text2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    56.     If Button = 1 Then
    57.         StartCapture Me.hwnd
    58.     End If
    59. End Sub

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