Problem scrolling array with btnbmp

Problem scrolling array with btnbmp

Postby Silvio.Falconi » Wed May 31, 2017 2:28 pm

I must scrolling 6 btnbmp categories write on the btnbmp as this (i cannot use xbrowse)

Image

the first and last btnbmp are to move the array on up and down

the problem I have it not run ok because on second move the first or last btnbmp is disabled and the user cannot move the array

this is the test

Code: Select all  Expand view
#include "FiveWin.ch"
#include "constant.ch"

#define LIGHTCYAN    nRGB( 203, 225, 252 )
#define  COLOR_BTNFACE  15

STATIC nPageLines, nElemenLines, nBloqueLine, nPageProdu, nBloqueProdu, nElemenProdu, aProduPorLinea
STATIC aDatosMesa,oBrwConsu
static oDlgmesas




STATIC FUNCTION TestCategory()
LOCAL nFraccion,nEntero,nLinea,aLineas
LOCAL aCargos
LOCAL nLin, lPrimer, nn
Local lsalida
LOCAL aBtnsLines, aBtnScroll
Local oBtnCat
lOCAL oFntButton
lOCAL CSCONUMDOC:= "001"

    //------------------- measure for the dialog
      Local nBottom   := 12
      Local nRight    := 66
      Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
      Local nHeight := nBottom * DLG_CHARPIX_H
    //-------------------------------------------------

aBtnsLines:= ARRAY(6)
aBtnScroll:= ARRAY(2)
aBtnsProdu:= ARRAY(24)
aBtnScroll:= ARRAY( 4)
aLineas   := {}
nLinea    := 0
nLin      := 1

lPrimer   := .T.
lSalida   := .F.

nPageLines  := 0
nElemenLines:= 6
nBloqueLine := 1

aLineas   := { {"1111","",1},;
               {"2222","",2},;
               {"3333","",3},;
               {"4444","",4},;
               {"5555","",5},;
               {"6666","",6},;
               {"7777","",7},;
               {"8888","",8},;
               {"9999","",9},;
               {"0000","",10},;
               {"AAAA","",11},;
               {"BBBB","",12},;
               {"CCCC","",13},;
               {"DDDD","",14},;
               {"EEEE","",15},;
               {"FFFF","",16},;
               {"GGGG","",17},;
               {"HHHH","",18},;
               {"IIII","",19}, ;
               {"LLLL","",20}}
    nLinea:= 20


nEntero   := INT( nLinea / 6 )
nFraccion := ( nLinea / 6 ) - nEntero
nFraccion := IF( nFraccion > 0, 1, 0 )
nPageLines:= nEntero + nFraccion

oFntButton              := TFont():New( "Segoe UI",  0, ( 24 ), .f., .t. )

DEFINE DIALOG oDlgMesas       ;
   TITLE "TEST"   ;
   SIZE nWidth, nHeight


                 @   5,70 BTNBMP aBtnsLines[ 1] OF  oDlgMesas  SIZE 48, 30 PIXEL  GDIP 2007
                 @   5,120 BTNBMP aBtnsLines[ 2] OF  oDlgMesas  SIZE 48, 30 PIXEL  2007
                 @   5,170 BTNBMP aBtnsLines[ 3] OF  oDlgMesas  SIZE 48, 30 PIXEL  2007
                 @  37,20 BTNBMP aBtnsLines[ 4] OF  oDlgMesas  SIZE 48, 30 PIXEL   2007
                 @  37,70 BTNBMP aBtnsLines[ 5] OF  oDlgMesas  SIZE 48, 30 PIXEL   2007
                 @  37,120 BTNBMP aBtnsLines[ 6] OF  oDlgMesas  SIZE 48, 30 PIXEL  2007





  aCargos:= { "   ", "          " }


 FOR EACH oBtnCat IN aBtnsLines
     IF hb_EnumIndex() <= Len( aLineas )
       oBtnCat:cCaption:= ( AllTrim( aLineas[ hb_EnumIndex(), 1 ] ))

      * oBtnCat:nClrTextDis:= CLR_WHITE

     *  oBtnCat:nClrText:= { |oB| If( oB:lMOver, CLR_WHITE, CLR_RED ) }
      * oBtnCat:nClrBack:= { |oB| If( oB:lMOver, { nRgb(0,119,176), nRgb(255,255,255), 1 }, ;
     *                                            { nRgb(128,128,255), nRgb(255,255,255), 1 } ) }

       oBtnCat:cargo   := { .F., aLineas[hb_EnumIndex(), 3] }
       oBtnCat:bAction := { || AEVAL( aBtnsLines, ;
                          { |oB| IF( oB:lPressed, (oB:lPressed:= .F., oB:cargo[1]:= .F.,;
                             oB:nClrpane:= { nRgb(128,128,255), nRgb(255,255,255), 1 },oB:refresh() ), .F. ) } ), ;
                            oBtnCat:cargo[1]:= !oBtnCat:cargo[1], ;
                        If( oBtnCat:cargo[1], ;
                          ( oBtnCat:lPressed := .T., ;
                            oBtnCat:nClrpane:= { nRgb(0,119,176 ), nRgb(255,255,255), 5 }, ;
                            GetProductoPorLinea( oBtnCat:cargo[2], aBtnsProdu, oBrwConsu, aBtnScroll, ;
                                                 cScoNumDoc, oFntButton ) ) , ;
                          ( oBtnCat:lPressed := .F., oBtnCat:cargo[2]:= "   ",;
                            oBtnCat:nClrpane:= { nRgb(128,128,255), nRgb(255,255,255), 1 } ) ), ;
                            oBtnCat:refresh() }
      oBtnCat:oFont:= oFntButton
       oBtnCat:Refresh()
     ELSE
        oBtnCat:disable()
     ENDIF
  NEXT





  @  5,20 BTNBMP aBtnScroll[1] OF  oDlgMesas prompt "<==" SIZE 48, 30 PIXEL CENTER 2007      ;
                  ACTION OnActionUpLines( @aBtnsLines, aLineas, aCargos, aBtnScroll, oBrwConsu, aBtnsProdu)



 @  37,170   BTNBMP aBtnScroll[2]  OF  oDlgMesas prompt "==>" SIZE 48, 30 PIXEL CENTER 2007    ;
                   ACTION OnActionDownLines( @aBtnsLines, aLineas, aCargos, aBtnScroll, oBrwConsu, aBtnsProdu)






 IF LEN( aLineas ) <= 6
   aBtnScroll[1]:Disable()
   aBtnScroll[1]:Refresh()

   aBtnScroll[2]:Disable()
   aBtnScroll[2]:Refresh()
     ENDIF


ACTIVATE DIALOG oDlgMesas
RETUR NIL


   FUNCTION GetProductoPorLinea
    RETUR NIL




 STATIC FUNCTION OnActionDownLines( aBtns, aArrayLinea, aCargos, aBtnScroll, oBrw, aBtnsPro )
  LOCAL nn, oBProdu

  ++nBloqueLine

  IF nBloqueLine <= nPageLines
   /*  FOR EACH oBProdu IN aBtnsPro
       *  oBProdu:nClrText:= CLR_GRAY
      *   oBProdu:cCaption:= ""
      *   oBProdu:nClrBack:= GetSysColor( COLOR_BTNFACE )
       *  oBProdu:Refresh()
      *   oBProdu:enable()
   NEXT
   */

     FOR nn:= 1 TO LEN( aBtns )
         WITH OBJECT aBtns[nn]
              IF ( nn + nElemenLines ) <= LEN( aArrayLinea )
                 :cCaption:= ( AllTrim( aArrayLinea[ nn + nElemenLines, 1 ] ))
                 :cargo   := { .F., aArrayLinea[ nn + nElemenLines, 3] }
             *    :nClrBack:= { |oB| If( oB:lMouseOver, { nRgb(0,119,176), nRgb(255,255,255), 1 }, ;
              *                                         { nRgb(128,128,255), nRgb(255,255,255), 1 } ) }
                 :Enable()
                 :Refresh()
              ELSE
                 :nClrText:= CLR_GRAY
                 :cCaption:= ""
               *  :nClrBack:= GetSysColor( COLOR_BTNFACE )
                 :Refresh()
                 :Disable()
              ENDIF
         END
      NEXT nn



     nElemenLines += 6
  ELSE
     nBloqueLine:= nPageLines
  ENDIF


  IF nBloqueLine == nPageLines
     aBtnScroll[2]:Disable()
     aBtnScroll[2]:Refresh()
    aBtnScroll[1]:Enable()
     aBtnScroll[1]:Refresh()
  ENDIF

  RETURN NIL


STATIC FUNCTION OnActionUpLines( aBtns, aArrayLinea, aCargos, aBtnScroll, oBrw, aBtnsPro )
  LOCAL nn, oBProdu

  --nBloqueLine

  IF nBloqueLine <= 0
     nBloqueLine:= 1
  ENDIF

  IF nBloqueLine <= nPageLines
    /* FOR EACH oBProdu IN aBtnsPro
      *   oBProdu:nClrText:= CLR_GRAY
      *   oBProdu:cCaption:= ""
      *   oBProdu:nClrBack:= GetSysColor( COLOR_BTNFACE )
      *   oBProdu:Refresh()
      *   oBProdu:enable()
     NEXT
      */

     nElemenLines -= 12
     IF nElemenLines <= 0
        nElemenLines:= 0
     ENDIF

     FOR nn:= 1 TO LEN( aBtns )
         WITH OBJECT aBtns[nn]
              IF ( nn + nElemenLines ) <= LEN( aArrayLinea )
                 :cCaption:= ( AllTrim( aArrayLinea[ nn + nElemenLines, 1 ] ))
                 :cargo   := { .F., aArrayLinea[ nn + nElemenLines, 3] }
              *   :nClrBack:= { |oB| If( oB:lMouseOver, { nRgb(0,119,176), nRgb(255,255,255), 1 }, ;
              *                                         { nRgb(128,128,255), nRgb(255,255,255), 1 } ) }
                 :cargo   := { .F., aArrayLinea[nn + nElemenLines, 3] }
                 :Enable()
                 :Refresh()
              ELSE
               *  :nClrText:= CLR_GRAY
                 :cCaption:= ""
                * :nClrBack:= GetSysColor( COLOR_BTNFACE )
                 :Refresh()
                 :Disable()
              ENDIF
         END
      NEXT nn

     IF nElemenLines <= 0
        nElemenLines:= 6
     ENDIF
  ENDIF

  IF nBloqueLine == 1
     aBtnScroll[1]:Disable()
     aBtnScroll[1]:Refresh()
  else
      aBtnScroll[1]:Enable()
     aBtnScroll[1]:Refresh()
  ENDIF

  aBtnScroll[2]:Enable()
  aBtnScroll[2]:Refresh()

  RETURN NIL

 




after compiled the test

I see correct all records
I can move on down button and on up button all records and see 6 records each times

the problem is this:

make these operations

down button is ==>
UP button is <==


1. I press down button I can see the other 6 record ( second page)

2. I press down button I can see the other 6 record ( third page)

3. I press up button I can turn back ultil the top then this button is disabled because you are on the top of array then I press the down button to see other record

4. now you 'll see the up button disabled and you cannot press this button to return back you can only press the down button and arrive to the end and then you 'll see the up button enable

why ?

I hope you help me . thanks
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: 7034
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem scrolling array with btnbmp

Postby gabo » Wed May 31, 2017 4:08 pm

Silvio
This code is very old, but is a guide
Code: Select all  Expand view

nPageLines= Int( Total the "groups or lines" the  table or dbf / 6  )
//------------------------------------------------------------------------------
STATIC FUNCTION OnActionDownLines( aBtns, aArrayLinea, aCargos, aBtnScroll, oBrw, aBtnsPro ) // Your last Button Corner Right
  LOCAL nn, oBProdu

  ++nBloqueLine // Counter the 6 "button Line" per block  

  IF nBloqueLine <= nPageLines
     FOR EACH oBProdu IN aBtnsPro
         oBProdu:nClrText:= CLR_GRAY
         oBProdu:cCaption:= ""
         oBProdu:nClrBack:= GetSysColor( COLOR_BTNFACE )
         oBProdu:Refresh()
         oBProdu:enable()
     NEXT
     FOR nn:= 1 TO LEN( aBtns )
         WITH OBJECT aBtns[nn]
              IF ( nn + nElemenLines ) <= LEN( aArrayLinea )
                 :cCaption:= Str2Lines( AllTrim( aArrayLinea[ nn + nElemenLines, 1 ] ), " " )
                 :cargo   := { .F., aArrayLinea[ nn + nElemenLines, 3] }
                 :nClrBack:= { |oB| If( oB:lMouseOver, { nRgb(0,119,176), nRgb(255,255,255), 1 }, ;
                                                       { nRgb(128,128,255), nRgb(255,255,255), 1 } ) }
                 :Enable()
                 :Refresh()
              ELSE
                 :nClrText:= CLR_GRAY
                 :cCaption:= ""
                 :nClrBack:= GetSysColor( COLOR_BTNFACE )
                 :Refresh()
                 :Disable()
              ENDIF
         END
     NEXT nn
     nElemenLines += 12
  ELSE
     nBloqueLine:= nPageLines
  ENDIF

  IF nBloqueLine == nPageLines
     aBtnScroll[2]:Disable()
     aBtnScroll[2]:Refresh()
     aBtnScroll[1]:Enable()
     aBtnScroll[1]:Refresh()
  ENDIF

  RETURN NIL

//------------------------------------------------------------------------------
STATIC FUNCTION OnActionUpLines( aBtns, aArrayLinea, aCargos, aBtnScroll, oBrw, aBtnsPro ) // You Firs Button Corner Left
  LOCAL nn, oBProdu

  --nBloqueLine

  IF nBloqueLine <= 0
     nBloqueLine:= 1
  ENDIF

  IF nBloqueLine <= nPageLines
     FOR EACH oBProdu IN aBtnsPro
         oBProdu:nClrText:= CLR_GRAY
         oBProdu:cCaption:= ""
         oBProdu:nClrBack:= GetSysColor( COLOR_BTNFACE )
         oBProdu:Refresh()
         oBProdu:enable()
     NEXT

     nElemenLines -= 24
     IF nElemenLines <= 0
        nElemenLines:= 0
     ENDIF
     FOR nn:= 1 TO LEN( aBtns )
         WITH OBJECT aBtns[nn]
              IF ( nn + nElemenLines ) <= LEN( aArrayLinea )
                 :cCaption:= Str2Lines( AllTrim( aArrayLinea[ nn + nElemenLines, 1 ] ), " " )
                 :cargo   := { .F., aArrayLinea[ nn + nElemenLines, 3] }
                 :nClrBack:= { |oB| If( oB:lMouseOver, { nRgb(0,119,176), nRgb(255,255,255), 1 }, ;
                                                       { nRgb(128,128,255), nRgb(255,255,255), 1 } ) }
                 :cargo   := { .F., aArrayLinea[nn + nElemenLines, 3] }
                 :Enable()
                 :Refresh()
              ELSE
                 :nClrText:= CLR_GRAY
                 :cCaption:= ""
                 :nClrBack:= GetSysColor( COLOR_BTNFACE )
                 :Refresh()
                 :Disable()
              ENDIF
         END
     NEXT nn
     IF nElemenLines <= 0
        nElemenLines:= 12
     ENDIF
  ENDIF

  IF nBloqueLine == 1
     aBtnScroll[1]:Disable()
     aBtnScroll[1]:Refresh()
  ENDIF

  aBtnScroll[2]:Enable()
  aBtnScroll[2]:Refresh()

  RETURN NIL

 


Regards
gabo
 
Posts: 128
Joined: Tue Jan 03, 2006 8:31 pm

Re: Problem scrolling array with btnbmp

Postby Silvio.Falconi » Wed May 31, 2017 4:22 pm

Gabriel thanks
I have this :
nLinea is totale of records

nPageLines := 0
nElemenLines:= 6
nBloqueLine := 1

nEntero := INT( nLinea / 6 )
nFraccion := ( nLinea / 6 ) - nEntero
nFraccion := IF( nFraccion > 0, 1, 0 )
nPageLines:= nEntero + nFraccion


the problemis on second or thirs times the up button is disabled
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: 7034
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem scrolling array with btnbmp

Postby Silvio.Falconi » Wed May 31, 2017 4:30 pm

Now I press the last button (down)

Image

now I press the first button (up)

Image

Now I press the last button (down)

Image

now I press the first button (up)

Image


and now I cannot see the categories but the button have not the text

why ?
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: 7034
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem scrolling array with btnbmp

Postby Otto » Wed May 31, 2017 5:23 pm

Hello Silvio,
how is the speed of painting the buttons.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6313
Joined: Fri Oct 07, 2005 7:07 pm

Re: Problem scrolling array with btnbmp

Postby Silvio.Falconi » Wed May 31, 2017 5:27 pm

Otto I don't Understood
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: 7034
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 46 guests