Problem with drag xbrowse

Problem with drag xbrowse

Postby Silvio.Falconi » Fri Dec 21, 2018 9:44 pm

I must insert some lines from one xbrowse to another
the first xbrowse have datasource from a dbf
the second have a array empty

Image


when I drag from the first to second it not make anything ( and it not make error)

the first xbrowse (oBrw1) have image at first columns the same into second xbrowse ( oBrw2)
I wish also when I drag into second xbrowse If there is allready the same record it must add to quantity ( 4th column)

I need it for create a multiple service example :
the service two bed are two record bed


Code: Select all  Expand view  RUN

#include "Fivewin.ch"
#define  pict_money_Euro   "€ 999,999.99"

function InsertMultiple()

       local oDlg, oBrw1, oBrw2, oCur
       local aData:={}
       local aget[9]

     Local cCodice    //incremental
     Local cName := space(30)
     Local nPrice  := 0
     Local cImage  := space(60)
     Local nUnit  := 0
     Local lA4   :=.f.
     Local lPos  :=.f.

        /* cCodice :=SE->Id
         cName   :=SE->name
         nPrice  :=SE->price
         cImage  :=SE->image
         nUnit   :=SE->unit
         lA4     :=SE->a4
         lPos    :=SE->pos*/


       //take only the services not multiple to make selection
       use servizi alias SE
       set filter to se->multiple=.F.
       go top

       aBrowse     :=  {{"IMAGE",i18n("Tipo"),nil,50 },;
                        { "NAME",i18n("Descrizione"),nil,290 },;
                        { "PRICE",i18n("Importo"), pict_money_Euro,80 }}


      cImage :=""
    cDefaImage:="noImage.png"


      DEFINE CURSOR oCur DRAG
      DEFINE DIALOG oDlg SIZE 878, 480 PIXEL;   // SIZE 878, 570
             Title "Inserimento Servizi Multipli "  ;
              STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                       WS_MAXIMIZEBOX, WS_MINIMIZEBOX, WS_THICKFRAME )

     @ 1, 12 SAY "Servizi singoli " size 100, 12  OF oDlg

     @ 2,2 XBROWSE oBrw1   OF oDlg ;
          COLUMNS aBrowse  CELL LINES  NOBORDER   ;
          DATASOURCE "SE" SIZE 200, 90  STYLE  2015


    WITH OBJECT oBrw1
       :nRowHeight    := 30

      WITH OBJECT oBrw1:aCols[ 1]
          :lBmpStretch     := .F.
          :lBmpTransparent := .T.
          :nwidth := 30
          :bStrImage       := {|| se->IMAGE }
       END

         :oDragCursor   := oCur
         :bDragBegin    := { |r,c,f| SetDropInfo( oBrw1:SelectedCol():Value ) }

          :CreateFromCode()
       END


 // second Browse

     @ 1, 52 SAY "Servizi selezionati " size 100, 12  OF oDlg
     @ 2,28 XBROWSE oBrw2 OF oDlg;
   COLUMNS 1, 2, 3, 4  ;
   HEADERS "Tipo","Descrizione","Prezzo","Quantità"  ;
   COLSIZES 30,80,60,60         ;
   ARRAY aData  SIZE 200, 90   NOBORDER  STYLE  2015


     WITH OBJECT oBrw2
    :nRowHeight    := 30
      WITH OBJECT oBrw2:aCols[ 1]
          :lBmpStretch     := .F.
          :lBmpTransparent := .T.
          :nwidth := 30
          :bStrImage       := {|| oBrw2:aArrayData[ oBrw2:narrayat][1] }
       END

         * :bDropOver  := { |u,r,c,f| DropOver( u,r,c, oBrw1, oBrw2 ) }
          :bDropOver  := { |uInfo,r,c,f,aPt| oBrw2:SetPos( aPt[ 1 ], aPt[ 2 ], .t. ), ;
                                         oBrw2:SelectedCol():VarPut( uInfo ) }

          :CreateFromCode()
       END






   @ 124,10 Say "Nome del servizio :" SIZE 90,10 PIXEL OF oDlg
   @ 122,75 GET aGet[2] VAR cName OF oDlg SIZE 95,10 PIXEL

   @ 138,10 Say "Prezzo :" SIZE 50,10 PIXEL OF oDlg
   @ 136,135 GET aGet[3] VAR nPrice OF oDlg SIZE 35,10 PIXEL  RIGHT

   @ 154,10 CHECKBOX aGet[6] VAR lA4 Prompt "Visibile nella stampa A4" SIZE 150,10 PIXEL OF oDlg
   @ 172,10 CHECKBOX aGet[7] VAR lPos Prompt "Visibile nella stampa Pos" SIZE 150,10 PIXEL OF oDlg

   @ 122,200 Say "Immagine :" SIZE 50,10 PIXEL OF oDlg
   @ 130,275 Button "Carica"  SIZE 30,10 PIXEL OF oDlg ;
   ACTION (cFile:= GetImage( cImage ),aGet[4]:SetSource( cFile ))

   @ 136,220 XIMAGE aGet[4] SOURCE IF(empty(cImage),cDefaImage,cImage) SIZE 50, 50 OF oDlg







   @ 200, ScreenWidth() / 15 + 200 FLATBTN PROMPT "Ok" ;
          SIZE 50, 20 ACTION ( lOk := .T., oDlg:End() )

   @ 200, ScreenWidth() / 15 + 270 FLATBTN PROMPT "Cancel" ;
          SIZE 50, 20 ACTION oDlg:End()

       ACTIVATE DIALOG oDlg CENTERED




    return nil
//------------------------------------------------------------------------//
    function DropOver( uInfo, nRow, nCol, oBrw1, oBrw2 )

       local aPoint

       aPoint      := ClientToScreen( oBrw1:hWnd, { nRow, nCol } )
       aPoint      := ScreenToClient( oBrw2:hWnd, aPoint )

       oBrw2:SetPos( aPoint[ 1 ], aPoint[ 2 ], .t. )
       oBrw2:SelectedCol():VarPut( uInfo )

       return nil

       function GetImage( oImage )

   local gcFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" +         ;
                             "JPEG  (*.jpg)| *.jpg|"  +         ;
                             "PNG  (*.png)| *.png|"           ;
                            ,"Please select a image file", 4 )

   if ! Empty( gcFile ) .and. File( gcFile )

   endif

return gcFile

 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with drag xbrowse

Postby Marc Venken » Sat Dec 22, 2018 8:10 am

Here was a sample from the forum :
Maybe it can be helpfull.


Code: Select all  Expand view  RUN

// FiveWin - own Drag&Drop new features !!!
// Drag item from one listbox to another listbox

#include "FiveWin.ch"
#include "xbrowse.ch"

//----------------------------------------------------------------------------//

function Main()

   local oWnd, oCursor, oLbx, oLbx2
   local cItem:=""

   DEFINE CURSOR oCursor hand

   DEFINE WINDOW oWnd TITLE "FiveWin's own Drag & Drop features!!!"


   @ 6, 3 XBROWSE oLbx OF oWnd COLUMNS 1 ;
      ARRAY { "Item 1","Item 2","Item 3","Item 4" } SIZE 200, 200

   // Set a DropOver action for the ListBox
   oLbx:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
                        AAdd( oLbx:aArrayData,  oLbx2:aArrayData[ uDropInfo ] ), ;
                        ADel( oLbx2:aArrayData, uDropInfo, .t. ), ;
                        oLbx:Refresh(.t.), oLbx2:Refresh(.t.) }

   oLbx:oDragCursor = oCursor         // Select a Drag cursor
   oLbx:bDragBegin  = { | nRow, nCol, nKeyFlags | ;
                        SetDropInfo( oLbx:nArrayAt ),;   // Save drop info !!!
                        oWnd:SetMsg( "Dragging..." ) }

   @ 6, 30 XBROWSE oLbx2 OF oWnd COLUMNS 1 ARRAY {} size 200,200
   oLbx2:bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
                        AAdd( oLbx2:aArrayData,  oLbx:aArrayData[ uDropInfo ] ), ;
                        ADel( oLbx:aArrayData, uDropInfo, .t. ), ;
                        oLbx:Refresh(.t.), oLbx2:Refresh(.t.) }

   oLbx2:oDragCursor = oCursor         // Select a Drag cursor
   oLbx2:bDragBegin  = { | nRow, nCol, nKeyFlags | ;
                        SetDropInfo( oLbx2:nArrayAt ),;   // Save drop info !!!
                        oWnd:SetMsg( "Dragging..." ) }


   oLbx:CreateFromCode()
   oLbx2:CreateFromCode()

   // Set a DropOver action for the ListBox

   SET MESSAGE OF oWnd ;
      TO "FiveWin - own DragDrop interface !!!" CENTER

   ACTIVATE WINDOW oWnd MAXIMIZED

return nil


 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1447
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Problem with drag xbrowse

Postby Silvio.Falconi » Sat Dec 22, 2018 8:38 am

Yes Mark, I saw this sample on forum ..this morning


as you can see here the problem ...is another

when I drag the record it is dragged

but on 4th column (quantity) must be add if the product dragged is the same

Image

Code: Select all  Expand view  RUN
     



       // FiveWin - own Drag&Drop new features !!!
    // Drag item from one listbox to another listbox

    #include "FiveWin.ch"
    #include "xbrowse.ch"

    //----------------------------------------------------------------------------//

    function Main()

       local oDlg, oCursor, oLbx, oLbx2
       local cItem:=""
       local aData:= CreateArray_Servizi()

       DEFINE CURSOR oCursor hand


        DEFINE DIALOG oDlg SIZE 878, 480 PIXEL;   // SIZE 878, 570
             Title "Inserimento Servizi Multipli "  ;
              STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                       WS_MAXIMIZEBOX, WS_MINIMIZEBOX, WS_THICKFRAME )

        @ 1, 12 SAY "Servizi singoli " size 100, 12  OF oDlg

        @ 2,2 XBROWSE oLbx OF oDlg COLUMNS 1,2,3,4 ;
          ARRAY aData SIZE 200, 90  ;
          HEADERS "Tipo","Descrizione","Prezzo","Quantità"

     WITH OBJECT oLbx
         :nRowHeight    := 30
       // Set a DropOver action for the ListBox
        :bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
                            AAdd( oLbx:aArrayData,  oLbx2:aArrayData[ uDropInfo ] ), ;//
                            ADel( oLbx2:aArrayData, uDropInfo, .t. ), ;
                            oLbx:Refresh(.t.), oLbx2:Refresh(.t.) }

         :oDragCursor = oCursor         // Select a Drag cursor
         :bDragBegin  = { | nRow, nCol, nKeyFlags | ;
                            SetDropInfo( oLbx:nArrayAt ) }   // Save drop info !!!
                             *}  //oWnd:SetMsg( "Dragging..." )

        WITH OBJECT oLbx:aCols[ 1]
          :lBmpStretch     := .F.
          :lBmpTransparent := .T.
          :nwidth := 30
          :bStrImage       := {|| oLbx:aArrayData[ oLbx:narrayat][1] }
       END
       :CreateFromCode()
    END




       @ 1, 52 SAY "Servizi selezionati " size 100, 12  OF oDlg

       @ 2,28 XBROWSE oLbx2 OF oDlg COLUMNS 1,2,3,4 ARRAY {} SIZE 200,90 ;
           HEADERS "Tipo","Descrizione","Prezzo","Quantità"



        WITH OBJECT oLbx2
         :nRowHeight    := 30

       :bDropOver = { | uDropInfo, nRow, nCol, nKeyFlags | ;
                            AAdd( oLbx2:aArrayData,  oLbx:aArrayData[ uDropInfo ] ), ;// ADel( oLbx:aArrayData, uDropInfo, .t. ), ;
                            oLbx:Refresh(.t.), oLbx2:Refresh(.t.) }

       :oDragCursor = oCursor         // Select a Drag cursor
       :bDragBegin  = { | nRow, nCol, nKeyFlags | ;
                            SetDropInfo( oLbx2:nArrayAt )}   // Save drop info !!!
                           * oWnd:SetMsg( "Dragging..." ) }

        WITH OBJECT oLbx2:aCols[ 1]
          :lBmpStretch     := .F.
          :lBmpTransparent := .T.
          :nwidth := 30
          :bStrImage       := {|| oLbx2:aArrayData[ oLbx2:narrayat][1] }
       END
      :CreateFromCode()
 END




       ACTIVATE DIALOG oDlg CENTERED

    return nil

    //----------------------------------------------------------------------------//




    Function CreateArray_Servizi()
     Local cImgProduct
     Local cDescProduct
     Local nPriceProduct
     Local lPrintA4
     Local lPrintPos

     local lMultiple
     local cDescBreve
     local cStruttura

     Local aDataProduct:={}
      //name price image a4 pos
     USE SERVIZI ALIAS SE
    SELECT SE
    SE->(DbGotop())

   DO WHILE .not. SE->(EOF())
        cImgProduct  :=SE->IMAGE
        cDescProduct :=SE->NAME
        nPriceProduct:=SE->PRICE
        lPrintA4     := SE->A4
        lPrintPos    := SE->POS
        lMultiple    := SE->MULTIPLE
        cDescBreve   := SE->BREVE
        cStruttura   := SE->STRUTTURA


      IF !lMultiple
        AaDd(aDataProduct,{cImgProduct,;
                           cDescProduct,;
                           nPriceProduct,;
                           1,;
                           lPrintA4,;
                           lPrintPos,;
                           lMultiple,;  //se è composto
                           cDescBreve,;
                           cStruttura}) // struttura se è composto
        ENDIF

      SE->(DBSKIP())

   ENDDO
   RETURN aDataProduct




















 


HOW I can Update the quantity on lbx2 if the product is the same ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with drag xbrowse

Postby Silvio.Falconi » Sat Dec 22, 2018 10:04 am

On this test I use the mouse
If the user use a tablet and not have a mouse how I can make to insert comand on some buttons?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 65 guests