FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Drag and Drop Xbrowse Cells
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Drag and Drop Xbrowse Cells
Posted: Sat Oct 10, 2015 11:24 AM
I would swap the values from one cell to another with the draganddrop system
the procedure changes the value of the new position with the value taken by the mouse but does not exchange the value of the new position with the position from which the value has been taken

I made this small test

Code (fw): Select all Collapse
   function xbr_array_dragdrop()

       local oDlg, oFont, oBrw, oDragCur
       local aData // [10,6]

       Local cCellaClasse,nPos1,nPos2


        aData:={{"5A","5A","","","",""},;
                {"2C","2C","4C","","",""},;
                {"","3RIM","4D","2D","2D",""},;
                {"5TM","5TM","","2B","1A",""},;
                {"4A","4A","","","",""}}




       DEFINE CURSOR oDragCur DRAG
       DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
       DEFINE DIALOG oDlg SIZE 790,400 PIXEL FONT oFont

       @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
          DATASOURCE aData AUTOCOLS CELL LINES NOBORDER

       WITH OBJECT oBrw
           :nWidths       := 40
           :lAllowColSwapping   := .f.   // no spostamento colonne
           :lAllowRowSizing     := .f.   // no ridimensionamento
           :lAllowColHiding     := .f.
           :nRowHeight                    := 22
           :nheaderHeight                 := 40

           :nColDividerStyle := LINESTYLE_BLACK
           :nRowDividerStyle := LINESTYLE_BLACK

      :oDragCursor   := oDragCur
      :bDragBegin    := { |r,c,f,o| (SetDropInfo( o:SelectedCol():Value ),;
                             nPos1:= r,nPos2:=c ) }
      :bDropOver     := { |u,r,c,f| oBrw:SetPos( r, c, .t. ), ;
                           cCellaClasse:= oBrw:SelectedCol():Value , ;
                           oBrw:SelectedCol():VarPut( u )     , ;
                           oBrw:SetPos( nPos1, nPos2, .t. )   , ;
                           IIf(!empty(cCellaClasse),;
                               oBrw:SelectedCol():VarPut( cCellaClasse ),;
                               oBrw:SelectedCol():VarPut( "" )              ),;
                           cCellaClasse:="",;
                           nPos1:=0,;
                           nPos2:=0  }

          //
          :CreateFromCode()
       END

       for nI = 1 to 6
          oBrw:aCols[ nI ]:bClrStd   := ChangeColor( oBrw, nI )
       next

       ACTIVATE DIALOG oDlg CENTERED
       RELEASE FONT oFont

    return nil

      static function ChangeColor( oBrw, n )
return {|| { CLR_BLACK, ColorCell( oBrw:aRow[ n ] ) } }

static function ColorCell( ctesto )
   local nColor

   Do case
   case ctesto="5A"
      nColor := 16744703
   case ctesto="2C"
      nColor :=   32896
   case ctesto="4D"
      nColor :=  16711935
   case ctesto="3RIM"
      nColor := 14414920
   case ctesto="4C"
      nColor := 33023
   case ctesto="2D"
      nColor := 16762623
   case ctesto="5TM"
      nColor :=  11334282
   case ctesto="2B"
      nColor := 8454143
   case ctesto="1A"
      nColor := 8421631
   case ctesto="4A"
      nColor := 12303359


        OTHERWISE
          nColor :=   GetSysColor( 15 )


      endcase



this test run ok then when I insert this system intoa big array it not run ok why ?
How I can resolve it ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion