Supposing I just want to highlight three (or any number of) random documents (.docx) or jpegs in Windows Explorer - i.e. I won’t yet have a clearly defined list that I can pre-set in the code - and then paste these chosen files somewhere within my Clarion app. Does the Clarion CLIPBOARD() function, or some other function, inherently know which files have been selected by the user in Windows and, if so, can it be interrogated to reveal & list their names? Hope that makes sense. Most documentation I can find seems to suggest that CLIPBOARD can only handle/return strings.
Use FileLookupButton control template or FILEDIALOGA() to let the user select files from inside the Clarion application.
That is what i normally do to let users select files.
I am not aware of any examples to allow copy-pasting multiple file(names) from explorer into Clarion.
Not sure if i understand what you need, but Drag&Drop does work for multiple files. It will be a comma or semicolon separated list of filenames.
ps. Somehow the first selected file will be the last in that list.
I can say, based on past experience, that supporting this stuff can be a whole lot of work, even if you’re already comfortable with these APIs. We hired a dev around 15 years ago to help us to support all of the explorer features in a SysTree and SysList. It was very involved. Worked, though.
Thanks all for the updates. For the moment, it does look like we’d be quicker getting our proposed “Paste” button to invoke a small c# .exe, which could then use the ready-made Microsoft functions to copy a list of selected files to the database file we use for attachments. After that I’ll be ready to retire.
I’m pleased to report that the code segment posted above works and took less than ten minutes to implement. Please accept my proposal of marriage, if indeed this is permitted in your time zone and/or state legislature. I’m sure my wife is fine with it.
One minor drawback appears to be that if you open Outlook, select an email, highlight an attachment, right-click & copy, this is not picked up by the functions and the message reads as having “zero files in the clipboard”. However, this probably only needs a small tweak, is way better than what we had before.
I was considering “flag this reply” since it caused a raucous amount of laughter just behind my keyboard, thereby negating several minutes of valuable work time.
Outlook uses a type of ‘virtual folders’ when copying attachments to the clipboard, so you’d have to use the CFSTR_FILECONTENTS and CFSTR_FILEDESCRIPTOR formats. It’s not as straight forward as getting a list of files from Explorer, so perhaps somebody else here already has a working example? If not I could probably put something together - if and when I have some spare time!
Edit: The OLE Drag & Drop example you can find in Github (posted previously by Carl) has what you need.
Carl’s project is very helpful in finding the information items available on the clipboard. Also this utility:
Explorer and Outlook enter data to the clipboard differently, here is an example for both cases:
-Read paths and names of copied files from windows explorer (CF_HDROP)
-Read the names of attached files copied from Outlook 365 and the content of the first one only (FileGroupDescriptor and FileContents)
All done only with the included CLIPBOARD function. In the case of CF_HDROP (copying from the explorer) it uses a single API to convert Unicode to Ansi, so the included support does help, although as you can see in the code, access through APIs is easier in this case.
From Outlook there is a difficulty if you select multiple files to copy. The technique to access the attachments from the second onwards is more complex, to access the lindex field. There is code in the mentioned Devuna Ole Drag and Drop project that references the IDataObject interface GetData method, FORMATETC structure.