Results 1 to 5 of 5

Thread: Another ListView Drag Drop Question

  1. #1

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Another ListView Drag Drop Question

    Hi All,

    Please tell me how to do this. When I drag across from one listview to another I want the dragimage to show the actual text being dragged accross but with sort of a watermarked effect. Any help would be greatly appreciated.

    Thanks.

  2. #2

  3. #3
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Another ListView Drag Drop Question

    How about something like this:

    VB Code:
    1. Option Explicit
    2. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
    3.     hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    4.     lParam As Any) As Long
    5.  
    6. Const LB_FINDSTRING = &H18F
    7. Const LB_FINDSTRINGEXACT = &H1A2
    8. Const CB_FINDSTRING = &H14C
    9. Const CB_FINDSTRINGEXACT = &H158
    10.  
    11. Dim strText As String
    12. Dim blnFlag As Boolean
    13.  
    14. Private Sub Form_Load()
    15. Dim a As Integer
    16.     For a = 1 To 10
    17.         List1.AddItem "Item " & a
    18.     Next a
    19.    
    20.     With Text1
    21.         .Appearance = 0
    22.         .BackColor = BackColor
    23.         .BorderStyle = 0
    24.         .ForeColor = &HC0C0C0
    25.         .Text = ""
    26.         .Visible = False
    27.     End With
    28.  
    29. End Sub
    30.  
    31. Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    32.    
    33.     If Button = 1 Then
    34.         strText = List1.Text
    35.         Text1.Text = strText
    36.         Text1.Visible = True
    37.         blnFlag = True
    38.     End If
    39.  
    40. End Sub
    41.  
    42. Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    43.    
    44.     If blnFlag Then
    45.         Text1.Move X, Y
    46.     End If
    47. End Sub
    48.  
    49. Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    50.    
    51.     If blnFlag Then
    52.         List2.AddItem strText
    53.         List1.RemoveItem (ListBoxFindString(List1, strText))
    54.     End If
    55.  
    56. Text1.Visible = False
    57. blnFlag = False
    58. End Sub
    59.  
    60. Private Function ListBoxFindString(ctrl As Control, ByVal search As String, _
    61.     Optional startIndex As Long = -1, Optional ExactMatch As Boolean) As Long
    62.    
    63.     'This Function was created by: Francesco Balena
    64.     'and can be found at: [url]http://www.devx.com/vb2themax/Tip/19121[/url]
    65.    
    66.     Dim uMsg As Long
    67.     If TypeOf ctrl Is ListBox Then
    68.         uMsg = IIf(ExactMatch, LB_FINDSTRINGEXACT, LB_FINDSTRING)
    69.     ElseIf TypeOf ctrl Is ComboBox Then
    70.         uMsg = IIf(ExactMatch, CB_FINDSTRINGEXACT, CB_FINDSTRING)
    71.     Else
    72.         Exit Function
    73.     End If
    74.     ListBoxFindString = SendMessage(ctrl.hWnd, uMsg, startIndex, ByVal search)
    75. End Function

    But you will have to figure out how to make the textbox transparent but you can probably do that use the code in this LINK to do that
    Last edited by Mark Gambo; Aug 2nd, 2007 at 08:16 AM.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  4. #4

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: Another ListView Drag Drop Question

    Quote Originally Posted by Mark Gambo
    How about something like this:

    VB Code:
    1. Option Explicit
    2. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
    3.     hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    4.     lParam As Any) As Long
    5.  
    6. Const LB_FINDSTRING = &H18F
    7. Const LB_FINDSTRINGEXACT = &H1A2
    8. Const CB_FINDSTRING = &H14C
    9. Const CB_FINDSTRINGEXACT = &H158
    10.  
    11. Dim strText As String
    12. Dim blnFlag As Boolean
    13.  
    14. Private Sub Form_Load()
    15. Dim a As Integer
    16.     For a = 1 To 10
    17.         List1.AddItem "Item " & a
    18.     Next a
    19.    
    20.     With Text1
    21.         .Appearance = 0
    22.         .BackColor = BackColor
    23.         .BorderStyle = 0
    24.         .ForeColor = &HC0C0C0
    25.         .Text = ""
    26.         .Visible = False
    27.     End With
    28.  
    29. End Sub
    30.  
    31. Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    32.    
    33.     If Button = 1 Then
    34.         strText = List1.Text
    35.         Text1.Text = strText
    36.         Text1.Visible = True
    37.         blnFlag = True
    38.     End If
    39.  
    40. End Sub
    41.  
    42. Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    43.    
    44.     If blnFlag Then
    45.         Text1.Move X, Y
    46.     End If
    47. End Sub
    48.  
    49. Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    50.    
    51.     If blnFlag Then
    52.         List2.AddItem strText
    53.         List1.RemoveItem (ListBoxFindString(List1, strText))
    54.     End If
    55.  
    56. Text1.Visible = False
    57. blnFlag = False
    58. End Sub
    59.  
    60. Private Function ListBoxFindString(ctrl As Control, ByVal search As String, _
    61.     Optional startIndex As Long = -1, Optional ExactMatch As Boolean) As Long
    62.    
    63.     'This Function was created by: Francesco Balena
    64.     'and can be found at: [url]http://www.devx.com/vb2themax/Tip/19121[/url]
    65.    
    66.     Dim uMsg As Long
    67.     If TypeOf ctrl Is ListBox Then
    68.         uMsg = IIf(ExactMatch, LB_FINDSTRINGEXACT, LB_FINDSTRING)
    69.     ElseIf TypeOf ctrl Is ComboBox Then
    70.         uMsg = IIf(ExactMatch, CB_FINDSTRINGEXACT, CB_FINDSTRING)
    71.     Else
    72.         Exit Function
    73.     End If
    74.     ListBoxFindString = SendMessage(ctrl.hWnd, uMsg, startIndex, ByVal search)
    75. End Function

    But you will have to figure out how to make the textbox transparent but you can probably do that use the code in this LINK to do that
    Thanks alot Mark,

    I'll give it a go now.

  5. #5
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Another ListView Drag Drop Question

    Good Luck!!!!
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


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