forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Drag and Drop

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Rubes_sw
Valued Contributor
Valued Contributor


Joined: 11 Jun 2001
Posts: 625
Location: Northern Ireland

PostPosted: Thu Nov 01, 2007 8:01 pm    Post subject: Drag and Drop Reply with quote

Is there anyway to do the following:?

Have a list (in a Table Element), filenames for example. Click and drag the name onto a Windows Desktop, Folder etc and have the VDS copy the file from its current location to the new location ?

APIs?, DLL?

I've been wrecking my brain for a solution but no luck so far...

Nathan
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Nov 02, 2007 2:59 pm    Post subject: Reply with quote

Unfortunately VDS does not fire an event when you drag and drop something from the dialog to another program or dialog. The way VDS does drag and drop is kinda strange to say the least but doing drag and drop is not a simple task to begin with. I will have to think about this one and get back with. I suspect it will take a DLL to override the VDS drag and drop or just don't make the dialog drag and drop at all and let the DLL handle the drag and drop. Like I said it will take some time to think about this scenario.
_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Fri Nov 02, 2007 3:19 pm    Post subject: Reply with quote

Could be done with the browser element, of course. But you would have to have the files as the only files in the folder you were displaying in the browser element. And I don't know if there is a way to force the "list" or "details" view.
_________________
Joe Floyd
Back to top
View user's profile Send private message
Rubes_sw
Valued Contributor
Valued Contributor


Joined: 11 Jun 2001
Posts: 625
Location: Northern Ireland

PostPosted: Fri Nov 02, 2007 3:28 pm    Post subject: Reply with quote

Could you:

1. Click on an item in the table
2. Change the mouse icon to include a file attacged to it
3. If you click on any other windows area, desktop, folder
4. Get the name of the location, using @mousepoint?
5. Then get the program to copy the file

So it looks like its dragging but its not really ?

Is this possible?

I have a great program, and i've checked online and theres not really anything like it (the way in which mine works), and this would be handy radther than getting a user to specify a folder etc.

N
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Fri Nov 02, 2007 10:19 pm    Post subject: Reply with quote

I was thinking the same as Rubes (Nathan?)

It'd be a bit messy but it should be possible to:

- Monitor mouse click events in the table/list
- Test if the left mouse button is held down
- Change mouse cursor to show a fake list item
- Monitor if the mouse cusor leaves the application's window (or is released)
- Monitor if the laft mouse button is released, and determine which application the mouse cursor is over.

But it'd be soooo much easier with a dll.

Anyone know if this behaviour has been improved in VDS6 Question

_________________
cheers

Dave
Back to top
View user's profile Send private message
trapper
Contributor
Contributor


Joined: 28 Jan 2005
Posts: 112
Location: Brisbane, Australia

PostPosted: Sat Nov 03, 2007 12:47 am    Post subject: Reply with quote

Garrett had a couple of examples of drag and drop a few years ago... I'm not sure if they would be useful. The thread links are here and here.

Cheers.

_________________
John Trappett
Back to top
View user's profile Send private message
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Sat Nov 03, 2007 8:04 am    Post subject: Reply with quote

They are cool nonetheless. Though I was able to create duplicate list items in the first example jusat by dragging it off the window, and somehow 'drag' a file in the 2nd example just by trying to select multiple items.
_________________
cheers

Dave
Back to top
View user's profile Send private message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Nov 03, 2007 7:03 pm    Post subject: Reply with quote

Yeah, fine for dragging from element to element within VDS itself or from Windows Explorer to VDS, but even I never figured out how to drag and drop from VDS to the Windows Explorer. Sad
_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sun Nov 04, 2007 11:13 am    Post subject: Reply with quote

Only solution I can think of, is by taking these steps:
  1. Let the user drag an item from VDS
  2. Do a while loop until the mouse button is released
  3. Find some way to put the file you want to copy on the clipboard (for example, copy it to an empty folder, open explorer.exe, send a Ctrl+C)
  4. Make the window below the mousebutton active (do a window click)
  5. Send the Ctrl+V key combination
I can work out an example, but it may not be very pretty Wink

Edit: Here it is Smile

Code:
option decimalsep,.

  DIALOG CREATE,Sleuren en pleuren example,-1,0,451,348
REM *** Gewijzigd door de Dialoog Ontwerper op 4-11-2007 - 12:32 ***
  DIALOG ADD,BITMAP,BITMAP1,85,89,92,80,c:\windows\explorer.exe,,CLICK,STRETCH
  DIALOG SHOW

:Evloop
wait event
goto @event()

:Bitmap1click
dialog cursor,drag
# Specify a filename
%%file = C:\test\temp.txt
# Wait until mouse button is up
while @mousedown()
  wait 0.1
wend
dialog cursor,wait
%%MouseX = @mousepos(X)
%%MouseY = @mousepos(Y)
%%Window = @winatpoint(%%MouseX,%%MouseY)
%%MouseX = @diff(%%MouseX,@winpos(%%Window,L))
%%MouseY = @diff(%%MouseY,@winpos(%%Window,T))
# Save this window's window id
%%CurrentWinId = @winactive()
# Open explorer
shell open,explorer,"/select,"%%file
# Wait until explorer is opened
%%MaxWaitTime = 20
while @both(@equal(%%CurrentWinId,@winactive()),@unequal(%%MaxWaitTime,0))
  wait 0.1
  %%MaxWaitTime = @pred(%%MaxWaitTime)
wend
if @equal(%%MaxWaitTime,0)
  # Something went wrong with opening Explorer
  error 33
end
# Set something on the clipboard to check when the file will be one
clipboard set,TEMPSTRING
wait 0.5
# Explorer opened, send Ctrl+C, keycodes from http://msdn2.microsoft.com/en-us/library/ms645540.aspx
loadlib user32.dll
%%Ctrl = 17
%%KeyC = 67
# Press keys
%x = @lib(user32,keybd_event,NULL:,INT:%%Ctrl,INT:0,INT:0,INT:0)
%x = @lib(user32,keybd_event,NULL:,INT:%%KeyC,INT:0,INT:0,INT:0)
# Lift keys
%x = @lib(user32,keybd_event,NULL:,INT:%%KeyC,INT:0,INT:$002,INT:0)
%x = @lib(user32,keybd_event,NULL:,INT:%%Ctrl,INT:0,INT:$002,INT:0)
freelib user32.dll
# Wait until file is on the clipboard
%%MaxWaitTime = 20
while @both(@equal(@clipbrd(),TEMPSTRING),@unequal(%%MaxWaitTime,0))
  wait 0.1
  %%MaxWaitTime = @pred(%%MaxWaitTime)
wend
if @equal(%%MaxWaitTime,0)
  # Something went wrong with copying the file onto the clipboard, windows
  # might have been switched or something else.
end
# Close window
window close,@winactive()
# Click at %%MouseX and %%MouseY
window click,%%Window,%%MouseX,%%MouseY
# Send Ctrl+V
loadlib user32.dll
%%Ctrl = 17
%%KeyV = 86
# Press keys
%x = @lib(user32,keybd_event,NULL:,INT:%%Ctrl,INT:0,INT:0,INT:0)
%x = @lib(user32,keybd_event,NULL:,INT:%%KeyV,INT:0,INT:0,INT:0)
# Lift keys
%x = @lib(user32,keybd_event,NULL:,INT:%%KeyV,INT:0,INT:$002,INT:0)
%x = @lib(user32,keybd_event,NULL:,INT:%%Ctrl,INT:0,INT:$002,INT:0)
freelib user32.dll
dialog cursor,normal
goto evloop

:Close
exit


Edit #2: Added a little debug code (like a timer to get out of an eternal loop) and the dialog cursor commands Smile

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!


Last edited by Skit3000 on Sun Nov 04, 2007 1:42 pm; edited 1 time in total
Back to top
View user's profile Send private message
Rubes_sw
Valued Contributor
Valued Contributor


Joined: 11 Jun 2001
Posts: 625
Location: Northern Ireland

PostPosted: Sun Nov 04, 2007 12:07 pm    Post subject: Reply with quote

Does not have to be pretty as long as it works .... Wink

As i said previously im working on a project and doing my research online, theres nothing really like it.. Some programs come close, but are akward to install and setup, and this is simplictly itself...

I dont way to say to much about the program until its complete....

N
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sun Nov 04, 2007 1:43 pm    Post subject: Reply with quote

If you can find another way for copying a file onto the clipboard you might be better of, but I thing the dropping part is as good as it can get Smile
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Mon Nov 05, 2007 5:00 pm    Post subject: Reply with quote

Skit3000 wrote:
If you can find another way for copying a file onto the clipboard you might be better of, but I thing the dropping part is as good as it can get Smile


Well you could do it the correct way which is to use the notification messages like LVN_BEGINDRAG which is the list view notification to start a drag n drop operation. To use these with VDS you need to hook them with a message hook. I was going to sub-class the VDS dialog to make this possible but there are so many possible scenarios I don't know if I could cover them all in a generic sub-class of these messages. It would be easier to hook the messages and then perform all the actions you want too during the drag n drop. It would be cleaner if I sub-class it with my DLL but there would need to be rules on how to use the messages since I cannot block in the sub-class when these messages are requested while VDS code is executing at the same time. Also I don't know if I could make it generic enough so you could use it with every element. I will probably only be able to make it work with the list's and table element types.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Rubes_sw
Valued Contributor
Valued Contributor


Joined: 11 Jun 2001
Posts: 625
Location: Northern Ireland

PostPosted: Mon Nov 05, 2007 6:35 pm    Post subject: Reply with quote

That would be cool if you could do it johnny...

N
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group