Problem with xbrowse

Problem with xbrowse

Postby Silvio.Falconi » Thu Jul 05, 2018 9:47 am

I load data from an archive and create an array aData

Image

then I create the xbrowse for only the first 5 field

@ 120, 05 XBROWSE oBrowse OF oDlg ;
COLUMNS 1, 2, 3, 4,5 ;
HEADERS "ico","Descrizione servizio","Q.tà","Prezzo","Totale" ;
COLSIZES 50, 120, 50, 90,90 ;
ARRAY aData LINES FASTEDIT CELL ;
SIZE 100,70 PIXEL

Image


on the first column i wish to show the image and I made

WITH OBJECT oBrowse:aCols[ 1]
:bFooter := { || Ltrim( Str( oBrowse:KeyNo() ) ) + " / " + LTrim( Str( oBrowse:KeyCount() ) )+" servizi" }
:lBmpStretch := .F.
:lBmpTransparent := .T.
:bStrImage := {|oCol, oBrw| aData[ oBrowse:nAt,1 ] }
END

but it not show the image

if click on hscroll it make an error
Code: Select all  Expand view
Application
===========
   Path and name: C:\Work\Errori\servizi_singoli\test.Exe (32 bits)
   Size: 3,770,368 bytes
   Compiler version: Harbour 3.2.0dev (r1703231115)
   FiveWin  version: FWH 17.12
   C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
   Windows version: 6.2, Build 9200

   Time from start: 0 hours 0 mins 19 secs
   Error occurred at: 07/05/18, 12:20:59
   Error description: Error BASE/1132  Bound error: array access
   Args:
     [   1] = A   { ... } length: 3
     [   2] = N   5

Stack Calls
===========
   Called from: test.prg => (b)TEST( 88 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTCELL( 12673 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTDATA( 12377 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DRAWLINE( 2557 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:REFRESHCURRENT( 2502 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:GORIGHT( 3551 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HSCROLL( 3318 )
   Called from:  => TWINDOW:HANDLEEVENT( 0 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1731 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT( 10297 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3356 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 296 )
   Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG( 436 )
   Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS( 23 )
   Called from: test.prg => (b)TEST( 88 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTCELL( 12673 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTDATA( 12377 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT( 2028 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY( 1752 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1697 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT( 10297 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3356 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 296 )
   Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG( 436 )
   Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS( 23 )
   Called from: test.prg => (b)TEST( 88 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTCELL( 12673 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTDATA( 12377 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DRAWLINE( 2557 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:REFRESHCURRENT( 2502 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:GORIGHT( 3551 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HSCROLL( 3318 )
   Called from:  => TWINDOW:HANDLEEVENT( 0 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1731 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT( 10297 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3356 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 296 )
   Called from: test.prg => TEST( 164 )
 



then I wish have the get on bottom because I wish have SubTotal, Descuent, and Total

the final user can insert the Descuent and the total must be refresh

I made a function to calculate the subtotal and the total but it past allway nsconto=0 and if the final user insert a value it past allway zero


Function CalcoloTotali(oBrowse)
Local n
nTotale:= 0
nSubtotale:= 0

For n=1 to Len(oBrowse:aArrayData)
nSubtotale+= oBrowse:aArrayData[n][5]
next

nTotale:=nSubTotale-nSconto

//Msginfo(nSconto)
// Msginfo(nSubTotale)
// Msginfo(ntotale)

aGet[3]:refresh()
aGet[5]:refresh()

oBrowse:Refresh()
oBrowse:GoBottom()


return nil
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with xbrowse

Postby Marc Venken » Thu Jul 05, 2018 10:22 am

For the images

Code: Select all  Expand view

   @ 1,1 XBROWSE oBrw OF oDlg SIZE 330,430 PIXEL DATASOURCE "showpic" ;
      COLUMNS "pic1","pic2","pic3" COLSIZES 200, 200,200 ;
      CELL LINES NOBORDER


   WITH OBJECT oBrw
      :nRowHeight := 200
      WITH OBJECT :aCols[ 1 ]
         :bStrImage     := { || "r:\pictures\"+alltrim(showpic->pic1) }
         :oDataFont     := oBold
         :nDataStrAlign := AL_CENTER + AL_BOTTOM
         :nDataBmpAlign := AL_CENTER
         :aImgRect      := { nil, nil, -40, nil }
      END
      WITH OBJECT :aCols[ 2 ]
         :bStrImage     := { || "
r:\pictures\"+alltrim(showpic->pic2) }
         :oDataFont     := oBold
         :nDataStrAlign := AL_CENTER + AL_BOTTOM
         :nDataBmpAlign := AL_CENTER
         :aImgRect      := { nil, nil, -40, nil }
      END
      WITH OBJECT :aCols[ 3 ]
         :bStrImage     := { || "
r:\pictures\"+alltrim(showpic->pic3) }
         :oDataFont     := oBold
         :nDataStrAlign := AL_CENTER + AL_BOTTOM
         :nDataBmpAlign := AL_CENTER
         :aImgRect      := { nil, nil, -40, nil }
      END

      //
      :CreateFromCode()
   END

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

Re: Problem with xbrowse

Postby Marc Venken » Thu Jul 05, 2018 10:27 am

XBrowse make the totals himself. But I think that you a looking for a other solution.

I think your solution is in the sample Yunus.prg (invoice)

Code: Select all  Expand view

      for each cCol in { "Amount", "Tax", "Total" }
         oBrw:oCol( cCol ):nFooterType  := AGGR_SUM
      next

      oBrw:bLDblClick = { || oBrw:EditSource(,, .T.) }
      oBrw:bEdit = { | oRec | EditInvoice( oRec ) }
      oBrw:MakeTotals()
      oBrw:CreateFromCode()
      oBrw:SetFocus()
 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Problem with xbrowse

Postby Silvio.Falconi » Thu Jul 05, 2018 10:36 am

for the image
I have the string into the array
I made

WITH OBJECT oBrowse:aCols[ 1]
:bFooter := { || Ltrim( Str( oBrowse:KeyNo() ) ) + " / " + LTrim( Str( oBrowse:KeyCount() ) )+" servizi" }
:lBmpStretch := .F.
:lBmpTransparent := .T.
:nwidth := 20
:bStrImage := {|oCol, oBrw| oBrw:aArrayData[ oBrw:nAt,1 ] }
END

but It show alway the same image
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with xbrowse

Postby Silvio.Falconi » Thu Jul 05, 2018 11:05 am

Please try this test

Code: Select all  Expand view
#include "fivewin.ch"
#include "dtpicker.ch"

Static ntotale,nSubTotale,nSconto
Static aGet,oSay


Function test()
Local oDlg,oFont
Local oBrowse


Local   aData:= { {".\bitmaps\1.bmp","LETTINO" ,1,5.00,5.00,"0000000001","05/07/18"},;
                      {".\bitmaps\2.bmp","SDRAIO",1,5.00,5.00,"0000000001", "05/07/18" },;
                      { ".\bitmaps\3.bmp","REGISTA",1,5.00,5.00 ,"0000000001","05/07/18"} }


   Local nScontrino:="0000000001"
   Local dDataEmissione := date()


   nSubTotale:=0
   nSconto:= 0
   nTotale:= 0
   aGet:= ARRAY(5)
   oSay := ARRAY(3)
 DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14

 DEFINE DIALOG oDlg SIZE 600,600 PIXEL;
 FONT oFont    Title "Servizi Singoli"  ;
 STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
              WS_MAXIMIZEBOX, WS_MINIMIZEBOX, WS_THICKFRAME )


 @ 12,5 SAY "Numero Scontrino :" OF  oDlg PIXEL SIZE 100,20 TRANSPARENT
 @ 10,75 GET aGet[1] VAR nScontrino  SIZE 100,12 PIXEL OF oDlg  READONLY

 @ 26,5 SAY "Data emissione :" OF  oDlg PIXEL SIZE 100,20 TRANSPARENT
* @ 24,75 DTPICKER aGet[2] VAR dDataEmissione SIZE 120,12 PIXEL OF oDlg  PICTURE "dddd, dd mmmm yyyy"




 @ 120, 05 XBROWSE  oBrowse OF oDlg ;
      COLUMNS 1, 2, 3, 4,5                    ;
      HEADERS "ico","Descrizione servizio","Q.tà","Prezzo","Totale"   ;
      COLSIZES 20, 100, 50, 90,90           ;
      ARRAY aData LINES FASTEDIT CELL       ;
      SIZE 280,70 PIXEL


 WITH OBJECT oBrowse

       WITH OBJECT oBrowse:aCols[ 1]
          :bFooter   := { || Ltrim( Str( oBrowse:KeyNo() ) ) + " / " + LTrim( Str( oBrowse:KeyCount() ) )+" servizi" }
          :lBmpStretch     := .F.
          :lBmpTransparent := .T.
          :nwidth := 30
          :bStrImage       := {|| oBrowse:aArrayData[ oBrowse:nAt][1] }
       END

                    WITH OBJECT  oBrowse:aCols[ 5]
                         :nFooterType      := AGGR_SUM
                          :cEditPicture := '@ €99,999.99'
                      END

                      :MakeTotals()
                      :lfooter          := .T.
                      :lHscroll         := .F.
                      :l2007            := .F.
                      :l2015            := .T.
                      :nStretchCol  := STRETCHCOL_WIDEST
                      :lAllowRowSizing     := .F.
                      :lAllowColSwapping   := .F.
                      :lAllowColHiding     := .F.

                      :CreateFromCode()
    END


 @ oBrowse:nBottom+5,5 SAY oSay[1] Prompt "SubTotale :" OF  oDlg PIXEL SIZE 70,20 TRANSPARENT
 @ oBrowse:nBottom+5,55 GET aGet[3] VAR nSubTotale  SIZE 40,12 PIXEL OF oDlg PICTURE '@ €99,999.99' READONLY

 @ oBrowse:nBottom+5,125 SAY oSay[2] Prompt "Sconto :" OF  oDlg PIXEL SIZE 70,20 TRANSPARENT
 @ oBrowse:nBottom+5,155 GET aGet[4] VAR nSconto  SIZE 40,12 PIXEL RIGHT PICTURE '@ €99,999.99' OF oDlg ;
 ON CHANGE CalcoloTotali(oBrowse)

 @ oBrowse:nBottom+5,205 SAY oSay[3] Prompt "Totale :" OF  oDlg PIXEL SIZE 70,20 TRANSPARENT
 @ oBrowse:nBottom+5,255 GET aGet[5] VAR nTotale  SIZE 40,12 PIXEL PICTURE '@ €99,999.99' OF oDlg  READONLY

ACTIVATE DIALOG oDlg CENTERED;
on init CalcoloTotali(oBrowse)


RETURN NIL


Function CalcoloTotali(oBrowse)
   Local n
   nTotale:= 0
   nSubtotale:= 0

    For n=1 to Len(oBrowse:aArrayData)
        nSubtotale+=  oBrowse:aArrayData[n][5]
     next

     nTotale:=nSubTotale-nSconto

   Msginfo(nSconto)
   Msginfo(nSubTotale)
   Msginfo(ntotale)

   aGet[3]:refresh()
   aGet[5]:refresh()

   oBrowse:Refresh()
   oBrowse:GoBottom()


   return nil

 

insert 3 different images on .\bitmaps\ and rename with number from 1 to 3
sample 1.bmp

if you insert a value on second get it call the function CalcoloTotali(oBrowse) but it past allway 0 (zero)
if you del the last caracter of this get for a sample the last zero then it make right the calc
How I can resolve ?
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with xbrowse

Postby nageswaragunupudi » Thu Jul 05, 2018 2:12 pm

In your first posting:
Code: Select all  Expand view
:bStrImage := {|oCol, oBrw| aData[ oBrowse:nAt,1 ] }

The error is that you used oBrowse:nAt.
You should have used oBrowse:nArrayAt

Anyway, there is a much simpler approach than using bStrImage.
Instead of using
Code: Select all  Expand view
:bStrImage := {|oCol, oBrw| aData[ oBrowse:nAt,1 ] }

Simply write
Code: Select all  Expand view
:cEditPicture := "F"
Regards

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

Re: Problem with xbrowse

Postby Silvio.Falconi » Thu Jul 05, 2018 2:51 pm

Mr Rao I not saw your message and on lunch I tried with

:bStrImage := {|| oBrowse:aArrayData[ oBrowse:narrayat][1] }

and for the problem of the get ( it lose the value initial) on the get I insert aGet[4]:assign()

and run all

with :cEditPicture := "F" here not run perhaps I have an oldest rel of fwh
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 72 guests