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 RUN
- #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