Requirement: We need to find some way of using the Clarion CLIPBOARD() function to store a group of files, rather than text, and we’re going to click a button to paste these files to a specified location. We know that the clipboard function can be used to store simple text and perhaps other things depending on the parameter - see below for the Clarion Help list of parameters. However, can the Clarion clipboard function be used to store and then subsequently access this list of files? If it isn’t possible, we will need to look at using c# to do this. And I will probably need to look for a new job.
Build a list of files with some delimiter (like fileList = ‘file1.txt|file2.txt|file3.txt’) and do SETCLIPBOARD(fileList), then do fileList = CLIPBOARD() and parse the fileList. But this is a bad idea, a user may oberwrite clipboard contents between SETCLIPBOARD and CLIPBOARD calls.
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.
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.
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.