Link to home
Start Free TrialLog in
Avatar of jxharding
jxharding

asked on

right click & drag between 2 filelistboxes

i am writing an application that basically has two explorer bars, just like
norton commander
im using vb6


its looking like this

side 1                             side 2
____________________________________________________________________
DRIVELISTBOX1                DRIVELISTBOX2

DIRLISTBOX1                             DIRLISTBOX2

FILELISTBOX1             FILELISTBOX2

______________________________________________________________________


the user obviously selects a drive on side 1 and then
selects a directory from dirlistbox1 and then
filelistbox1 displays everything in that directory.
very very simple.


PROBLEM:
the main reason i am writing this program is to be able to utilize TOTAL COPY.
i need  to be able to right click and drag a file from side 1 to side 2.
___________________________________________
in case you dont know total copy:
if you are in a windows explorer and you
right click and drag a file to any locaton, you
will get the options :
copy here
move here
cancel

if you have total copy installed , you get
2 extra options:

1)total move here
1)total copy here

___________________________________________

in windows i usually opened 2 explorers and tiled them vertically, but thats
why i am writing the app now.



any ideas on how i can accomplish this, i am totally lost :)

be able to right click and drag a file from a filelistbox to another filelistbox or dirlistbox

Avatar of dbrckovi
dbrckovi
Flag of Croatia image

Hi!

Does it realy have to be right button? When using right button on File list box, then it doesn't update ListIndex property (it doesn't select an item in that Listbox)
I'll give you an example of how it could work, with using left button for dragging.

On an empty form create the same structure as you noted in your question, and then just add a textbox somewhere and change its name to txtFilePath.

If you want, you can change File1's and File2's DragIcon property to some icon, becouse otherwise it will display a big rectangle when dragging.

Now paste this code:

---------------------------------------------------------------
Dim SideClicked As Integer

Private Sub Dir1_Change()
    File1 = Dir1
End Sub

Private Sub Dir2_Change()
    File2 = Dir2
End Sub

Private Sub Drive1_Change()
    Dir1 = Drive1
    File1 = Dir1
End Sub

Private Sub Drive2_Change()
    Dir2 = Drive2
    File2 = Dir2
End Sub

Private Sub File1_DragDrop(Source As Control, X As Single, Y As Single)
    Dim SourcePath As String
    Dim DestinationPath As String

    SourcePath = txtFilePath.Text
    DestinationPath = Dir1 & "\"

    If SideClicked = 2 Then MsgBox SourcePath & " copied to " & DestinationPath

    SideClicked = 0
End Sub

Private Sub File1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    SideClicked = 1
    File1.Drag
    txtFilePath = Dir1 & "\" & File1
End Sub

Private Sub File2_DragDrop(Source As Control, X As Single, Y As Single)
    Dim SourcePath As String
    Dim DestinationPath As String

    SourcePath = txtFilePath.Text
    DestinationPath = Dir2 & "\"

    If SideClicked = 1 Then MsgBox SourcePath & " copied to " & DestinationPath
    SideClicked = 0
End Sub

Private Sub File2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    SideClicked = 2
    File2.Drag
    txtFilePath = Dir2 & "\" & File2
End Sub

-------------------------------------------------------------------

Now when you click on any File list box and drag mouse to another, message will appear saying which file was copied to where.

I didn't implement any code for copiing becouse I'm not sure what you ment by 'total copy'.
If you could explain what is the difference between total copy and regular copy, then I could probably make function that would do the copiing.

If you already know how to make souch function then it  could be easily implemented in the above example just by replacing  "Msgbox  . . ." line with "TotalCopy (SourcePath, DestinationPath)"
ASKER CERTIFIED SOLUTION
Avatar of dbrckovi
dbrckovi
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jxharding
jxharding

ASKER

thanks a lot!
could you please take a look at this program ?

http://www.petri.co.il/software/total_copy_11.zip

its 70k, and its the bomb, id love to find out how this guy does this fast copying,
you must see the speed compared to normal copy!

answer brilliant
thanks again
Thanx for accepting.

I'll try it and reply if I think of something, but i'm affraid that you won't get this in Visual Basic. That is; You won't get much faster copiing only with VB.
If you wish to speed it up then you should use C++ or some other lower-level programming language, even assembler, or you should find some dll, or Active X control which supports
Total Copy, or something simillar.

If the above program is freeware, then maybe contacting it's author could be usefoul. Maybe he/she alredy has souch routines, and is willing to give them.

Regards!