|
-
Aug 2nd, 2007, 04:27 AM
#1
Thread Starter
PowerPoster
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.
-
Aug 2nd, 2007, 07:31 AM
#2
Re: Another ListView Drag Drop Question
That is not an easy thing to accomplish so you may want to drop that idea for now.
-
Aug 2nd, 2007, 08:03 AM
#3
Re: Another ListView Drag Drop Question
How about something like this:
VB Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Const LB_FINDSTRING = &H18F
Const LB_FINDSTRINGEXACT = &H1A2
Const CB_FINDSTRING = &H14C
Const CB_FINDSTRINGEXACT = &H158
Dim strText As String
Dim blnFlag As Boolean
Private Sub Form_Load()
Dim a As Integer
For a = 1 To 10
List1.AddItem "Item " & a
Next a
With Text1
.Appearance = 0
.BackColor = BackColor
.BorderStyle = 0
.ForeColor = &HC0C0C0
.Text = ""
.Visible = False
End With
End Sub
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
strText = List1.Text
Text1.Text = strText
Text1.Visible = True
blnFlag = True
End If
End Sub
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If blnFlag Then
Text1.Move X, Y
End If
End Sub
Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If blnFlag Then
List2.AddItem strText
List1.RemoveItem (ListBoxFindString(List1, strText))
End If
Text1.Visible = False
blnFlag = False
End Sub
Private Function ListBoxFindString(ctrl As Control, ByVal search As String, _
Optional startIndex As Long = -1, Optional ExactMatch As Boolean) As Long
'This Function was created by: Francesco Balena
'and can be found at: [url]http://www.devx.com/vb2themax/Tip/19121[/url]
Dim uMsg As Long
If TypeOf ctrl Is ListBox Then
uMsg = IIf(ExactMatch, LB_FINDSTRINGEXACT, LB_FINDSTRING)
ElseIf TypeOf ctrl Is ComboBox Then
uMsg = IIf(ExactMatch, CB_FINDSTRINGEXACT, CB_FINDSTRING)
Else
Exit Function
End If
ListBoxFindString = SendMessage(ctrl.hWnd, uMsg, startIndex, ByVal search)
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."
-
Aug 2nd, 2007, 08:20 AM
#4
Thread Starter
PowerPoster
Re: Another ListView Drag Drop Question
 Originally Posted by Mark Gambo
How about something like this:
VB Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Const LB_FINDSTRING = &H18F
Const LB_FINDSTRINGEXACT = &H1A2
Const CB_FINDSTRING = &H14C
Const CB_FINDSTRINGEXACT = &H158
Dim strText As String
Dim blnFlag As Boolean
Private Sub Form_Load()
Dim a As Integer
For a = 1 To 10
List1.AddItem "Item " & a
Next a
With Text1
.Appearance = 0
.BackColor = BackColor
.BorderStyle = 0
.ForeColor = &HC0C0C0
.Text = ""
.Visible = False
End With
End Sub
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
strText = List1.Text
Text1.Text = strText
Text1.Visible = True
blnFlag = True
End If
End Sub
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If blnFlag Then
Text1.Move X, Y
End If
End Sub
Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If blnFlag Then
List2.AddItem strText
List1.RemoveItem (ListBoxFindString(List1, strText))
End If
Text1.Visible = False
blnFlag = False
End Sub
Private Function ListBoxFindString(ctrl As Control, ByVal search As String, _
Optional startIndex As Long = -1, Optional ExactMatch As Boolean) As Long
'This Function was created by: Francesco Balena
'and can be found at: [url]http://www.devx.com/vb2themax/Tip/19121[/url]
Dim uMsg As Long
If TypeOf ctrl Is ListBox Then
uMsg = IIf(ExactMatch, LB_FINDSTRINGEXACT, LB_FINDSTRING)
ElseIf TypeOf ctrl Is ComboBox Then
uMsg = IIf(ExactMatch, CB_FINDSTRINGEXACT, CB_FINDSTRING)
Else
Exit Function
End If
ListBoxFindString = SendMessage(ctrl.hWnd, uMsg, startIndex, ByVal search)
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.
-
Aug 2nd, 2007, 08:21 AM
#5
Re: Another ListView Drag Drop Question
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|