Ever want a user to email a certain file from your application (eg, a data file), but have trouble getting across how to "browse" to find that file? How about just putting a reference to the file on the clipboard and letting them "Paste" it into an email (which attaches it to the email)?
This is tested with Eudora v5 and Outlook 2003 and works!
Update Now you can pass either a single file by name, or an array of files. The array can be single or multi-dimentioned. If multi-dimentioned (like the result of ADIR()), the first column is used. (I have a feeling that Single-dimentioned arrays will Not work in VFP6, though I have only tested on VFP9)
It Seems that these multiple-file-selections work with Eudora, but not Outlook, which only gets the first item. Oh, well, maybe someone will offer help with "Shell IDList Array"s.
FUNCTION PutFileOnClipboard LPARAMETERS tc_or_a_FilePath
DECLARE INTEGER GetActiveWindow IN win32api DECLARE INTEGER OpenClipboard IN WIN32API ; LONG HWND_hWndNewOwner DECLARE INTEGER RegisterClipboardFormat IN WIN32API ; STRING @ LPCTSTR_lpszFormat DECLARE INTEGER EmptyClipboard IN win32api DECLARE LONG GlobalAlloc IN WIN32API ; LONG UINT_uFlags, ; LONG SIZE_T_dwBytes DECLARE LONG GlobalLock IN WIN32API ; LONG HGLOBAL_hMem Declare LONG RtlMoveMemory IN WIN32API ; LONG ptrIntoHere, STRING @ cFromHere, LONG cb DECLARE INTEGER GlobalUnlock IN WIN32API ; LONG HGLOBAL_hMem DECLARE LONG SetClipboardData IN WIN32API ; INTEGER UINT_uFormat, ; LONG HANDLE_hMem Declare LONG GlobalFree IN win32api ; LONG hmem DECLARE INTEGER CloseClipboard IN win32api
* in VFP9, one dimention arrays are always treated like [x,1] two-dimentioned arrays. * this code may not work with VFP6,7,8.. it should just get skipped. IF type('tc_or_a_FilePath[2,1]')='C' lcPath = JUSTPATH(lcAsciiFile) lcUnicodeHDrop = lcAsciiFile lnLen = ALEN(tc_or_a_FilePath,1) FOR lnI = 2 TO lnLen lcFile = IIF(EMPTY(JUSTPATH(tc_or_a_FilePath[lnI,1])),lcPath+tc_or_a_FilePath[lnI,1], tc_or_a_FilePath[lnI,1] ) lcUnicodeHDrop = lcUnicodeHDrop+CHR(0)+lcFile ENDFOR lcUnicodeHDrop = STRCONV(STRCONV(lcUnicodeHDrop,1),5) ENDIF