1

I have a screen where I can drag-and-drop files from a Windows folder to a list box. Once the file is drag-and-dropped, the list box displays the file path.

I want to be able to drag-and-drop the file directly from Outlook/Gmail. If the drag-and-drop fails, I want copy and paste options to be available.

Is it possible to paste a file from the clipboard, assuming it has been populated by the Outlook/Gmail copy option?

I want to read the copied file path (which is available in the clipboard), and show it to the user.

Shafraz Khahir
  • 145
  • 1
  • 2
  • 7

4 Answers4

2

Check out the data object that VFP provides with OLE drag-and-drop and in particular, its GetFormat and SetFormat methods.

Tamar

Tamar E. Granor
  • 3,817
  • 1
  • 21
  • 29
1

It is possible to paste from the clipboard. The Windows clipboard is stored in the VFP system variable called _cliptext. You can do this very simple test to see it in action:

  1. Select the text from your question and press Ctrl+C to copy it to the clipboard.
  2. From the command window in VFP type: ? _cliptext
  3. Your question will print to the VFP screen.
Ed Pecyna
  • 401
  • 3
  • 7
1

Ed is correct if it is raw text, such as the message body of an email. You could just assign something like..

thisform.yourEditBox.Text = _cliptext

However, if you are referring to the clip being a file name of an attachment to the email, that is different. What is the file content... is IT a text file, Word document, Image, PDF, ect. The only one you would really easily be able to get is that of the text file. If that is the case, and your clipboard has the full path and name of the file you want to display to the user, then do..

thisform.yourEditBox.Text = filetostr( _cliptext )
DRapp
  • 47,638
  • 12
  • 72
  • 142
1

To retrieve the filepath and filenames of the files copied to the clipboard, you can use this basic routine. You can enhance it as you like.

* filenames on clipboard

Declare integer OpenClipboard in user32 integer
Declare integer CloseClipboard in user32
Declare integer GetClipboardData in user32 integer
Declare integer DragQueryFile in shell32 integer, integer, string @, integer

private dh,nof,tt,fn

if OpenClipboard(0)=1
    * handle
    dh=GetClipboardData(15)
    * number of files
    nof=DragQueryFile(dh,-1,chr(0),0)

    * filenames
    for tt=1 to nof
         fn=space(1024)
         DragQueryFile(dh,tt-1,@fn,1024)
         ? strtran(alltrim(fn),chr(0),'')
    next
endif
CloseClipboard()
Jack
  • 11
  • 2