Page 1 of 1

drop to GET how ?

PostPosted: Wed May 24, 2023 4:53 am
by Jimmy
hi,

i have some GET and enable "DROPFILES"

Code: Select all  Expand view
  ON DROPFILES DoDropFiles( nRow, nCol, aFiles )


i try to found TGET and compare Position where i drop

Code: Select all  Expand view
PROCEDURE DoDropFiles( nRow, nCol, aFiles )
LOCAL ii, iMax, oObj, cVALTYPE
LOCAL aCtrls   := oMain:aControls

   cVALTYPE := VALTYPE(aFiles)
   FWLOG "VALTYPE", cVALTYPE, aFiles

   FOR ii := 1 TO LEN( aCtrls )
      oObj := aCtrls[ ii ]

      IF VALTYPE( oObj ) == "O"
         DO CASE
            CASE oObj:ClassName() == "TGET"
            IF oObj:nTop <= nRow .AND. nRow <= oObj:nTop + oObj:nHeight
               IF oObj:nLeft <= nCol .AND. nCol <= oObj:nLeft + oObj:nWidth

                  // drop to GET
                  IF cVALTYPE = "A"
                     oObj:cVarName := aFiles[1]
                  ELSE
                     oObj:cVarName := aFiles
                  ENDIF
                  oObj:refresh()

                  FWLOG oObj:nTop, nRow, oObj:nTop + oObj:nHeight
                  FWLOG oObj:nLeft, nCol, oObj:nLeft + oObj:nWidth

                  EXIT
               ENDIF
            ENDIF
         ENDCASE
      ELSE
         FWLOG "not Object", oObj
      ENDIF
   NEXT

RETURN


Position seems right in Logfile but it does not appear in GET ... is ::cVarName right :?:

---

Code: Select all  Expand view
STATIC oMain

PROCEDURE MAIN( cDbf1, cDbf2 )
LOCAL oText_1
LOCAL oText_2
LOCAL oBtn_1
LOCAL oBtn_2
LOCAL oBtn_3
LOCAL oBtn_4
LOCAL cDBF_1 := ""
LOCAL cDBF_2 := ""

   IF !EMPTY( cDbf1 )
      cDBF_1 := cDbf1
   ENDIF
   IF !EMPTY( cDbf2 )
      cDBF_2 := cDbf2
   ENDIF

   DEFINE WINDOW oMain FROM 0, 0 TO 600, 800 PIXEL TITLE "FiveWin Sync DBF Demo " + cVersion ICON "A1MAIN" NOMAXIMIZE NOMINIMIZE

      @ 010, 010 BUTTON oBtn_1 PROMPT FWString( "Source DBF" ) SIZE 100, 30 PIXEL ACTION( cDBF_1 := cGetFile( "DBF File(*.dbf)|*.dbf|", "Select any dbf file",, CURDIR() ), oText_1:refresh() ) OF oMain
      @ 010, 120 GET oText_1 VAR cDBF_1 SIZE 650, 30 PIXEL

      @ 080, 010 BUTTON oBtn_2 PROMPT FWString( "Target DBF" ) SIZE 100, 30 PIXEL ACTION( cDBF_2 := cGetFile( "DBF File(*.dbf)|*.dbf|", "Select any dbf file",, CURDIR() ), oText_2:refresh() ) OF oMain
      @ 080, 120 GET oText_2 VAR cDBF_2 SIZE 650, 30 PIXEL

   ACTIVATE WINDOW oMain ;
      ON DROPFILES DoDropFiles( nRow, nCol, aFiles ) ;
      CENTER

RETURN

Re: drop to GET how ?

PostPosted: Wed May 24, 2023 7:58 am
by Antonio Linares
Dear Jimmy,

Please try it this way:
Code: Select all  Expand view
                 IF cVALTYPE = "A"
                     oObj:VarPut( aFiles[1] )
                  ELSE
                     oObj:VarPut( aFiles )
                  ENDIF

Re: drop to GET how ?

PostPosted: Wed May 24, 2023 10:41 am
by nageswaragunupudi
Another alternative is to make the Get accept drop.
Sample:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oWnd, oGet, cVar := "Drop here"

   DEFINE WINDOW oWnd

   @ 40,20 GET oGet VAR cVar SIZE 400,20 PIXEL OF oWnd

   oGet:bDropFiles := { |r,c,aFiles| oGet:cText := aFiles[ 1 ] }
   DragAcceptFiles( oGet:hWnd, .t. )

   @ 90,20 BUTTON "CLOSE" SIZE 60,40 PIXEL OF oWnd ;
      ACTION MsgInfo( cVar )

   ACTIVATE WINDOW oWnd CENTERED

return nil

Now, drag a file and directly drop on the Get.

Re: drop to GET how ?

PostPosted: Wed May 24, 2023 12:32 pm
by csincuir
Hello Nages
Very nice example! Thank you.

Your example works correctly, but only with Window, with Dialog or Window MDI Child it doesn't work.

It is possible to work this option with Dialogs?

Best regards.

Carlos

Re: drop to GET how ?

PostPosted: Wed May 24, 2023 12:54 pm
by nageswaragunupudi
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oGet, cVar := "Drop here"

   DEFINE DIALOG oDlg SIZE 500,300 PIXEL TRUEPIXEL

   @ 40,20 GET oGet VAR cVar SIZE 400,20 PIXEL OF oDlg


   @ 90,20 BUTTON "CHECK" SIZE 60,40 PIXEL OF oDlg ;
      ACTION MsgInfo( cVar )

   oDlg:bInit  := <||
      oGet:bDropFiles := { |r,c,aFiles| oGet:cText := aFiles[ 1 ] }
      DragAcceptFiles( oGet:hWnd, .t. )
      return nil
      >

   ACTIVATE DIALOG oDlg CENTERED

return nil
 

Re: drop to GET how ?

PostPosted: Wed May 24, 2023 4:08 pm
by csincuir
Excellent, it worked very well!!
Thank you Nages.

Best regards.

Carlos.