/* GUIBEGIN WINDOW , 76, 220, 331, 180, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, FILES, Drag and Drop some files on this window FONT 8, 400, MS Shell Dlg LIST 12, 9, 282, 86, NOTIFY|BORDER|VSCROLL|HSCROLL|TABSTOP, , MyList DEND GUIEND */ /* * An example of handling the DROPFILES event of a REXX GUI * window. Note: The window must have the "Accept files" (FILES) * extra style. */ OPTIONS "C_CALL LABELCHECK WINFUNC NOSOURCE" LIBRARY rexxgui DO /* Register some Windows OS functions that we'll need to call when * we get the WM_DROPFILES message. */ FUNCDEF("DragAcceptFiles", ", void, 32u", "shell32") FUNCDEF("DragQueryCount", "32u, void, 32, void, void", "shell32", "DragQueryFile") FUNCDEF("DragQueryFile", "32u, void, 32u, str[260] stor, 32u", "shell32") /* If you want to also be able to determine the mouse pointer's * position where the icons were dropped inside your window, * then you can FUNCDEF and call DragQueryPoint. */ /* POINT = '32u, 32u' FUNCDEF("DragQueryPoint", "32u, void, struct POINT stor", "shell32") */ CATCH FAILURE CONDITION("M") RETURN END GuiErr = "SYNTAX" GuiHeading = 1 GuiCreateWindow('NORMAL') Again: DO FOREVER GuiGetMsg() CATCH SYNTAX CONDITION('M') SIGNAL Again CATCH HALT FINALLY GuiDestroyWindow() END RETURN /* ================== WM_DROPFILES ================== * This handles the DROPFILES message for my window. * * Reginald calls this when the user drops some * file icons on our window, or some control in our * window. * * ARG(1) is a handle that we'll need to pass to * some other OS functions in order to enumerate * the names of all files dropped on our window. * * If the files were dropped on some control, then * ARG(2) is a handle to that control. If they were * dropped on the window itself, then ARG(2) is GuiWindow. */ WM_DROPFILES: /* Get the count of how many icons were simultaneously * dragged and dropped on our window. (There could be * more than one icon). */ count = DragQueryCount(ARG(1), -1) IF ARG(2) == GuiWindow THEN DO GuiSay("There were" count "icons dropped on this window.") variable = "" END ELSE DO /* Get the REXX variable associated with the control handle. NOTE: * The returned variable name is upper-cased. */ variable = GuiInfo("VARIABLE", ARG(2)) GuiSay("There were" count "icons dropped on" variable || ".") /* Clear out the listbox. */ GuiSendMsg("MyList", "RESETCONTENT") END /* Get the name of each one of those icons' files. * We loop around a call to DragQueryFile(), and the * second arg tells which file's name we want. The * first file is number 0, the second file is number * 1, the third is number 2, etc. * * DragQueryFile() will return the file's name in * whatever variable we pass as the third arg. Below, * we use a variable named "Filename". */ DO i = 1 TO count DragQueryFile(ARG(1), i - 1, Filename, 260) /* If dropped on the listbox, add the filename. */ IF variable \== "" THEN GuiSendMsg("MyList", "ADDSTRING", , Filename) END /* If we handle WM_DROPFILES, we return an empty string */ RETURN ""