drop to GET how ?

drop to GET how ?

Postby Jimmy » Wed May 24, 2023 4:53 am

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
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1585
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: drop to GET how ?

Postby Antonio Linares » Wed May 24, 2023 7:58 am

Dear Jimmy,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: drop to GET how ?

Postby nageswaragunupudi » Wed May 24, 2023 10:41 am

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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: drop to GET how ?

Postby csincuir » 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
csincuir
 
Posts: 396
Joined: Sat Feb 03, 2007 6:36 am
Location: Guatemala

Re: drop to GET how ?

Postby nageswaragunupudi » Wed May 24, 2023 12:54 pm

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
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: drop to GET how ?

Postby csincuir » Wed May 24, 2023 4:08 pm

Excellent, it worked very well!!
Thank you Nages.

Best regards.

Carlos.
csincuir
 
Posts: 396
Joined: Sat Feb 03, 2007 6:36 am
Location: Guatemala


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 95 guests