Button and array
Posted: Thu Jul 20, 2006 10:15 am
If i want associate a action to many buttons with matricial array How i can I make it ? and to return the number of the button ?
example :
tot1:=20
to2:=8
bAction := {|oBtn| prenotamenu( oBtn ) ,oBtn:cCaption := "",oBtn:Disable( VK_RBUTTON ), oBtn:Refresh() }
aBtn:= { Array( tot1 ), Array( tot2 ) }
totarray := tot1*tot2
aAct := Array( totarray )
AFill( aAct, bAction )
nDisponibili:=0
nOccupati:=0
n := 1
fila := 60
FOR i := 1 TO tot2
nPassLarg := 0
col := 10
FOR k := 1 TO tot1
aCapt:=Str( camere->camera,3,0)
IF ! Empty(Pre_cam->Nome)
cbitmap="SEAT1" //rosso
nOccupati++
ELSE
nDisponibili++
cbitmap="SEAT2" // verde
Endif
IF ! Empty(Pre_cam->Nome)
@ Fila,(Col+nPassLarg) SBUTTON aBtn[n] RESOURCE cbitmap PIXEL;
OF oWnd ;
FONT oFont2 ;
CAPTION aCapt ;
COLOR GetSysColor(13), GetSysColor(1) ;
TEXT ON_CENTER ;
NOBOX ;
MESSAGE "Pulsante sinistro: Inserire la prenotazione. " + ;
"Pulsante destro: Cancellare la prenotazione." ;
TOOLTIP oemtoansi(aCapt ) ;
ACTION aAct
ELSE
@ Fila,(Col+nPassLarg) SBUTTON aBtn[n] RESOURCE cbitmap PIXEL;
OF oWnd ;
FONT oFont2 ;
CAPTION aCapt ;
COLOR GetSysColor(13), GetSysColor(1) ;
TEXT ON_CENTER ;
NOBOX ;
MESSAGE "Pulsante sinistro: Inserire la prenotazione. " + ;
"Pulsante destro: Cancellare la prenotazione." ;
TOOLTIP oemtoansi(aCapt ) ;
ACTION aAct
ENDIF
//ciclo
col += 65
n++
CAMERE->(dbskip())
cPosNome :=""
NEXT
fila +=65
NEXT
nAct := 1
For nEle := 1 To Len( aBtn )
For nSub := 1 To Len( aBtn[ nEle ] )
aBtn[ nEle, nSub ]:Cargo := aCapt[ nAct++ ]
aBtn[ nEle, nSub ]:bRClicked := {| oBtn| fCancel( oBtn ) }
Next
Next
thanks
example :
tot1:=20
to2:=8
bAction := {|oBtn| prenotamenu( oBtn ) ,oBtn:cCaption := "",oBtn:Disable( VK_RBUTTON ), oBtn:Refresh() }
aBtn:= { Array( tot1 ), Array( tot2 ) }
totarray := tot1*tot2
aAct := Array( totarray )
AFill( aAct, bAction )
nDisponibili:=0
nOccupati:=0
n := 1
fila := 60
FOR i := 1 TO tot2
nPassLarg := 0
col := 10
FOR k := 1 TO tot1
aCapt:=Str( camere->camera,3,0)
IF ! Empty(Pre_cam->Nome)
cbitmap="SEAT1" //rosso
nOccupati++
ELSE
nDisponibili++
cbitmap="SEAT2" // verde
Endif
IF ! Empty(Pre_cam->Nome)
@ Fila,(Col+nPassLarg) SBUTTON aBtn[n] RESOURCE cbitmap PIXEL;
OF oWnd ;
FONT oFont2 ;
CAPTION aCapt ;
COLOR GetSysColor(13), GetSysColor(1) ;
TEXT ON_CENTER ;
NOBOX ;
MESSAGE "Pulsante sinistro: Inserire la prenotazione. " + ;
"Pulsante destro: Cancellare la prenotazione." ;
TOOLTIP oemtoansi(aCapt ) ;
ACTION aAct
ELSE
@ Fila,(Col+nPassLarg) SBUTTON aBtn[n] RESOURCE cbitmap PIXEL;
OF oWnd ;
FONT oFont2 ;
CAPTION aCapt ;
COLOR GetSysColor(13), GetSysColor(1) ;
TEXT ON_CENTER ;
NOBOX ;
MESSAGE "Pulsante sinistro: Inserire la prenotazione. " + ;
"Pulsante destro: Cancellare la prenotazione." ;
TOOLTIP oemtoansi(aCapt ) ;
ACTION aAct
ENDIF
//ciclo
col += 65
n++
CAMERE->(dbskip())
cPosNome :=""
NEXT
fila +=65
NEXT
nAct := 1
For nEle := 1 To Len( aBtn )
For nSub := 1 To Len( aBtn[ nEle ] )
aBtn[ nEle, nSub ]:Cargo := aCapt[ nAct++ ]
aBtn[ nEle, nSub ]:bRClicked := {| oBtn| fCancel( oBtn ) }
Next
Next
thanks