1. Tracy Lamb
  2. PowerBuilder
  3. Wednesday, 20 July 2022 20:17 PM UTC

Hi friends,

Wondering if it's possible to drag a file from Filer Explorer and drop it on a datawindow?  I have a tab that allows the user to "attach" files to a workorder.  Right now, they right-click then select Add File.  The code calls GetFileOpenName to find the file, then processes accordingly.  Customer suggestion today was that it would be nice to just drag/drop to accomplish the same thing.  

~~~Tracy

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 21 July 2022 05:31 AM UTC
  2. PowerBuilder
  3. # Permalink

You need the windows API functions

subroutine DragAcceptFiles (long hWnd, boolean fAccept) library "shell32.dll"  
subroutine DragFinish (long hDrop) library "shell32.dll"  
function int DragQueryFileW (long hDrop, int iFile, ref string szFileName, int cb) library "shell32.dll"  

To allow the dropping of files to a control call

// allow drop to datawindow control dw_1
DragAcceptFiles (Handle (dw_1), TRUE)

Add an event (e.g. "dropfiles") with event ID pbm_dropfiles to get dropped files

long ll_i, ll_numFiles
string ls_file, ls_files[]

ls_File = Space(1024)

// first call gets number of files dragged  
// "handle" is a event parameter
ll_numFiles = DragQueryFileW (handle, 4294967295, ls_File, 1023)  

FOR ll_i = 1 To ll_numFiles
	ls_File = Space(1024)  
	// subsequent calls get file names from dragged object  
	DragQueryFileW (handle, ll_i - 1, ls_File, 1023)  
	
	ls_files [ll_i] = ls_file
NEXT   

DragFinish (handle)  

 

Comment
  1. Tracy Lamb
  2. Thursday, 21 July 2022 12:52 PM UTC
That's pretty cool Renee!

Works great. One question... What is the parameter in DragFinish (aul_drophandle) ? Should that be just the "handle" event parameter or the handle of the dw control?

  1. Helpful
  1. Andreas Mykonios
  2. Thursday, 21 July 2022 13:14 PM UTC
It's the argument that your event with pbm_dropfiles event id returns. René did mentioned that in the comment.

Andreas.

  1. Helpful
  1. René Ullrich
  2. Thursday, 21 July 2022 13:19 PM UTC
I corrected it to "handle".
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 21 July 2022 19:57 PM UTC
  2. PowerBuilder
  3. # 1

Hi Olan;

 All the STD Framework, related examples & presentations are stored on the SourceForge repository. They've been there for decades. You should not have any issues accessing that code base. If you do, then you need to contact your network team at your organization. They should not be blocking these type of repositories.

Regards ... Chris 

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Thursday, 21 July 2022 17:31 PM UTC
  2. PowerBuilder
  3. # 2

Chris, I tried to connect to the website you listed and got this:

Comment
  1. Mark Goldsmith
  2. Thursday, 21 July 2022 19:42 PM UTC
Worked for me!
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 20 July 2022 20:22 PM UTC
  2. PowerBuilder
  3. # 3

Hi Tracy;

 FYI: http://chrispollach.blogspot.com/2015/07/ddinto.html

HTH

Regards ... Chris 

 

Comment
  1. Chris Pollach @Appeon
  2. Thursday, 21 July 2022 22:09 PM UTC
Hi Everyone;

I fixed the link to SF from my Drag & Drop blog article to point to the correct download location now.

1,000 pardons - my bad, that was a very old link.

Regards ... Chris
  1. Helpful 1
  1. John Fauss
  2. Friday, 22 July 2022 20:28 PM UTC
No worries, Chris. Thank you for updating the link, and thanks for everything you do for the Community!
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 22 July 2022 21:40 PM UTC
You too John! ;-)
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.