Since I had some challenges implementing this I wanted to post what I ended up doing in case others might need it! There are references to other objects/structures that I have not included but If you ever need that part just let me know. Thanks again for your input - can't say it enough how much these forums help us out!
Chris Craft
/*** Declarations ***/
FUNCTION boolean IsClipboardFormatAvailable ( ulong nFormat ) LIBRARY 'user32.dll'
FUNCTION boolean OpenClipboard ( longptr hWnd ) LIBRARY 'user32.dll'
FUNCTION boolean EmptyClipboard ( ) LIBRARY 'user32.dll'
FUNCTION boolean CloseClipboard ( ) LIBRARY 'user32.dll'
FUNCTION longptr GetClipboardData ( ulong nFormat ) LIBRARY 'user32.dll'
FUNCTION Long ShellExecute (long hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, integer nShowCmd ) LIBRARY "shell32.dll" ALIAS FOR "ShellExecuteW"
FUNCTION ulong DragQueryFile( longptr hDrop, ulong nFile, ref string sFileName, ulong nCB ) LIBRARY 'shell32.dll' ALIAS FOR "DragQueryFileW"
SUBROUTINE DragAcceptFiles( longptr hWnd, boolean bAccept ) LIBRARY 'shell32.dll' ALIAS FOR "DragAcceptFiles"
SUBROUTINE DragFinish(longptr hDrop) LIBRARY "shell32.dll"
/*** RMB event ***/
// This determines if we have files in the Clipboard
IF guOS.IsClipboardFormatAvailable(CF_HDROP) THEN
App.im_PopUp.RMBAddItem("-", ipothis, "")
App.im_PopUp.RMBAddItem("Paste", ipothis, "le_paste")
END IF
/*** le_paste event ***/
LongPtr lptr
IF guOS.OpenClipboard(0) THEN
lptr = guOS.GetClipboardData(CF_HDROP)
ProcessFiles(lptr, TRUE)
guOS.CloseClipboard()
END IF
/*** ProcessFiles function ***/
public function integer processfiles (longptr aptrhandle, boolean abclipboard);
Long llKeyIdx
String lsFile
Integer liNdx, liFiles, liAllocate = 1024
// Always Clear the Array!
istr_DocInfo = istr_ClearInfo
// Get the Primary Key Idx
llKeyIdx = GetKeyIdx()
IF IsNull(llKeyIdx) THEN
MessageBox("Information", "Must have an Entry/ID in order to associate a file.")
RETURN 0
ELSEIF ibNoDocumentTypes THEN
MessageBox("Information", "Must have document types setup in order to associate a file.")
RETURN 0
END IF
// Get how many files were dropped so we can loop through them
ibProcessing = TRUE
SetPointer(HourGlass!)
lsFile = Space( liAllocate )
liFiles = guOS.DragQueryFile( aptrHandle, -1, lsFile, liAllocate )
FOR liNdx = 1 TO liFiles
istr_DocInfo[liNdx].RecordType = FILEDOC
// Get the File and load the array
lsFile = Space( liAllocate )
guOS.DragQueryFile( aptrHandle, liNdx - 1, lsFile, liAllocate )
istr_DocInfo[liNdx].FileLoc = lsFile
istr_DocInfo[liNdx].Descr = f_GetFileName(lsFile)
NEXT
// If the Files came from the Clipboard then call EmptyClipboard() instead of DragFinish()!
// NOTE: DragFinish() would cause Famous to Crash when the next OpenClipboard() is called!
IF abClipboard THEN
guOS.EmptyClipboard()
ELSE
guOS.DragFinish(aptrHandle)
END IF
// All done!
ibProcessing = FALSE
SetPointer(Arrow!)
// Launch Assign Window for the first Index - The others will get Processed in AssignDocument()
IF liFiles > 0 THEN
SetDocument(1)
END IF
RETURN 1
end function