Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Using Drag and Drop files

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Using Drag and Drop files
#13587
Posted by: DougA 2012-03-06 02:05:52
I've got a simple program that has three text controls that I wish to drop files onto.
Which simply doesn't work.  No evidence that the WM_DROPFILES is being called.

If I activate the 'accept files' at the window level, and drop files onto the window, that works.
What gives ?


/*
GUIBEGIN


WINDOW , 207, 167, 400, 200, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, FILES, Audio File Convert
   FONT 8, 400, MS Shell Dlg
   TEXT 6, 137, 389, 55, SUNKEN|GROUP, , ConBox, , Console box
   PUSH 347, 113, 40, 14, TABSTOP, , ExitButton, , Exit
   TEXT 13, 23, 106, 85, CENTER|VCENTER|GROUP, MODALFRAME|FILES|CLIENTEDGE, Convert_to_FLAC, , Convert to FLAC
   TEXT 137, 23, 106, 85, CENTER|VCENTER|GROUP, MODALFRAME|FILES|CLIENTEDGE, Convert_to_WAV, , Convert to WAV
   TEXT 262, 23, 106, 85, CENTER|VCENTER|GROUP, MODALFRAME|FILES|CLIENTEDGE, Convert_to_MP3, , Convert to MP3
DEND
GUIEND
*/
Options "CASELESS"
LIBRARY rexxgui, RxConsole

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")

  CATCH FAILURE
    CONDITION("M")
    RETURN
END




RootDir = directory()                /* Start up directory */

GuiErr = "SYNTAX"
GuiHeading = 1
GuiCreateWindow('NORMAL')

DO FOREVER
   GuiGetMsg()
   IF EXISTS('GuiObject') == 0 THEN DO
      IF EXISTS('GuiSignal') THEN DO
        If GuiSignal = 'CLOSE' then leave
      END
   END
  
   CATCH SYNTAX
         CONDITION()

   CATCH HALT

   FINALLY
      GuiDestroyWindow()
END
RETURN

/* Create console by converting 'ConBox'
 * ConSay(Con1,'text' <,'NOBREAK'>)
 * GuiGetMsg("CLEAR") to force console update
 * ConClear(Con1)
 * text = ConPull(Con1)
 * use "CHILD | NODEFAULT" on second+ con windows
*/
wm_initdialog:
  guigetctlplacement('ConBox','ConX' ,'ConY' , 'ConWidth', 'ConHeight')
  GuiRemoveCtl('ConBox')
  concreate('Con1', guiwindow, "CHILD | NODEFAULT",ConX, ConY, ConWidth, ConHeight)
  consetlimit(Con1,5000)
RETURN ""


WM_CLICK_ExitButton:
  GuiWake('CLOSE')
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).
  */
  ConSay(con1,"Begin:  DROPFILES")
  count = DragQueryCount(ARG(1), -1)

  IF ARG(2) == GuiWindow THEN DO      /* dropped on window ? */
    ConSay(Con1,"There were" count "icons dropped on this window.")
    variable = ""
  END
  ELSE DO                             /* dropped on variable */
    /* Get the REXX variable associated with the control handle. NOTE:
     * The returned variable name is upper-cased.
     */
    variable = GuiInfo("VARIABLE", ARG(2))
    ConSay(Con1,"There were" count "icons dropped on" variable || ".")
  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 "SourceName".
  */
  DO i = 1 TO count
    DragQueryFile(ARG(1), i - 1, SourceName, 260)
    path("FileName",SourceName,'J')
   /* Returns FileName.0 = drive
                      .1 = directory(s)
                      .2 = filename (with ext if 'J'option)
                      .3 = extension (if 'J' not used)
    */
    ConSay(con1,SourceName)
    GuiGetMsg("CLEAR")
  END
 
/* If we handle WM_DROPFILES, we return an empty string */
RETURN ""
Doug
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2017-6-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0