FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour drop to GET how ?
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
drop to GET how ?
Posted: Wed May 24, 2023 04:53 AM
hi,

i have some GET and enable "DROPFILES"
Code (fw): Select all Collapse
   ON DROPFILES DoDropFiles( nRow, nCol, aFiles )
i try to found TGET and compare Position where i drop
Code (fw): Select all Collapse
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 (fw): Select all Collapse
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
greeting,

Jimmy
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: drop to GET how ?
Posted: Wed May 24, 2023 07:58 AM
Dear Jimmy,

Please try it this way:
Code (fw): Select all Collapse
                  IF cVALTYPE = "A"
                     oObj:VarPut( aFiles[1] )
                  ELSE
                     oObj:VarPut( aFiles )
                  ENDIF
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: drop to GET how ?
Posted: Wed May 24, 2023 10:41 AM
Another alternative is to make the Get accept drop.
Sample:
Code (fw): Select all Collapse
#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.
Regards



G. N. Rao.

Hyderabad, India
Posts: 476
Joined: Sat Feb 03, 2007 06:36 AM
Re: drop to GET how ?
Posted: Wed May 24, 2023 12:32 PM

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

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: drop to GET how ?
Posted: Wed May 24, 2023 12:54 PM
Code (fw): Select all Collapse
#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
Regards



G. N. Rao.

Hyderabad, India
Posts: 476
Joined: Sat Feb 03, 2007 06:36 AM
Re: drop to GET how ?
Posted: Wed May 24, 2023 04:08 PM

Excellent, it worked very well!!

Thank you Nages.

Best regards.

Carlos.

Continue the discussion