@ 50,50 BTNBMP oBtn FILE "\fwh\bitmaps\metro\utilities.bmp" ;
PROMPT "Comandas" FLAT SIZE 130,100 PIXEL OF oDlg ;
COLOR CLR_WHITE, RGB( 120,136,85 )
oBtn:bPainted := { || oBtn:SayText( "F2", { 8, nil, nil, -8 } , "TR" ) }
#include "FiveWin.ch"
#include "constant.ch"
Function test()
Local oDlgVarianti
Local nBottom := 12
Local nRight := 65
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H
Local lSave := .F.
Local aBtnsVarianti :=array(8)
Local oBtnVar
Local aVariantes := {}
Local nLineaVariantes := 0
Local aBtnScrollVariantes:=array(2)
Local cProducto:="0011"
Local nQuantita:=1
Local oBrowse,nScontrino
//first search there is the modifier of this producto
*DBSelectArea( "VA" ); OrdSetFocus("VARIANT2")
use varianti alias VA
INDEX ON upper(VARIANTE) TAG VARIANT1 TO VARIANTI
INDEX ON upper(PRODUCTO) TAG VARIANT2 TO VARIANTI
OrdSetFocus("VARIANT2")
IF ! VA->(DbSeek( (cProducto),.T. ) )
llSave := .F.
msgAlert( i18n( "Il prodotto non ha varianti in archivio") + CRLF +;
i18n("per favore verificare ..." ) )
RETURN NIL
ELSE
lSave := .T.
ENDIF
IF lSave
select VA
VA->(DbSetOrder(1))
VA->(DbGoTop())
DO WHILE ! VA->(EoF())
IF va->producto==cProducto
++nLineaVariantes
AAdd( aVariantes, { VA->DESC1 ,VA->precio, VA->variante } )
ENDIF
DBSkip()
ENDDO
// se ci sono varianti
DEFINE DIALOG oDlgVarianti ;
TITLE"Selezione Varianti" ;
SIZE nWidth, nHeight
@ 10, 10 BTNBMP aBtnsVarianti[1] FLAT SIZE 48,30 PIXEL OF oDlgVarianti
@ 10, 60 BTNBMP aBtnsVarianti[2] FLAT SIZE 48,30 PIXEL OF oDlgVarianti
@ 10,110 BTNBMP aBtnsVarianti[3] FLAT SIZE 48,30 PIXEL OF oDlgVarianti
@ 10,160 BTNBMP aBtnsVarianti[4] FLAT SIZE 48,30 PIXEL OF oDlgVarianti
@ 45, 10 BTNBMP aBtnsVarianti[5] FLAT SIZE 48,30 PIXEL OF oDlgVarianti
@ 45, 60 BTNBMP aBtnsVarianti[6] FLAT SIZE 48,30 PIXEL OF oDlgVarianti
@ 45,110 BTNBMP aBtnsVarianti[7] FLAT SIZE 48,30 PIXEL OF oDlgVarianti
@ 45,160 BTNBMP aBtnsVarianti[8] FLAT SIZE 48,30 PIXEL OF oDlgVarianti
FOR EACH oBtnVar IN aBtnsVarianti
IF hb_EnumIndex() <= Len( aVariantes )
oBtnVar:cCaption:= aVariantes[ hb_EnumIndex(), 1 ] // caption
oBtnVar:SayText( aVariantes[ hb_EnumIndex(), 2 ], { 8, nil, nil, -8 } , "TR" )
oBtnVar:nClrText:= CLR_WHITE
* oBtnVar:nClrpane:= { |oB| If( oB:lMOver, { RGB( 120,136,85 ), nRgb(255,255,255), 1 }, ;
* { nRgb(0,174,0), nRgb(255,255,255), 1 } ) }
oBtnVar:cargo := { .F., aVariantes[hb_EnumIndex(), 3] }
oBtnVar:bAction := { || oBtnVar:cargo[1]:= !oBtnVar:cargo[1], ;
If( oBtnVar:cargo[1], ;
( oBtnVar:lPressed := .T., ;
oBtnVar:nClrpane:= RGB( 180,136,85 ), ;
OnActionVariantes( oBtnVar:cargo[2], oBrowse, cProducto, nScontrino ),;
IF( oBtnVar:lPressed ,(oBtnVar:lPressed := .F., oBtnVar:cargo[1]:= .F.,;
oBtnVar:nClrpane:= RGB( 120,136,85 ),;
oBtnVar:refresh() ),) ), ;
( oBtnVar:lPressed := .F., ;
oBtnVar:nClrpane:= RGB( 120,136,85 ) ) ), ;
oBtnVar:refresh() }
oBtnVar:Refresh()
ELSE
oBtnVar:disable()
ENDIF
NEXT
@ 10,210 BTNBMP aBtnScrollVariantes[1] OF oDlgVarianti SIZE 30, 30 PIXEL File "BMP_UP_BTN.BMP" NOBORDER ;
ACTION nil
@ 45,210 BTNBMP aBtnScrollVariantes[2] OF oDlgVarianti SIZE 30, 30 PIXEL File "BMP_DOWN_BTN.BMP" NOBORDER ;
ACTION nil
ACTIVATE DIALOG oDlgVarianti CENTER
ENDIF
return nil
//--------------------------------------------------------------------------------------//
Function OnActionVariantes( cVariante, oBrowse, cProducto, nScontrino )
Msginfo(cVariante,cProducto)
return nil
#include "fivewin.ch"
function Main()
local oDlg, oFont, aVariantes, oBtnVariante, x, y, n
aVariantes := { { "One", "F2", "First Button" }, ;
{ "Two", "F3", "Second Button" }, ;
{ "Three", "F4", "Third Button" } }
oBtnVariante := Array( Len( aVariantes ) )
DEFINE FONT oFont NAME "ARIAL" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 500,300 PIXEL FONT oFont
x := 10
y := 10
for n := 1 to Len( aVariantes )
oBtnVariante[ n ] := CreateBtn( x, y, aVariantes[ n ], oDlg, oFont )
x += 50
if x >= 160
x := 10
y += 35
endif
next
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
Return nil
function CreateBtn( x, y, aVar, oDlg, oFont )
local oBtn
@ y, x BTNBMP oBtn ;
PROMPT aVar[ 1 ] SIZE 48,30 PIXEL OF oDlg 2007 ;
COLOR CLR_WHITE,RGB( 120,136,85 ) FONT oFont ;
ACTION ( ::GoDown(), ;
OnActionVariantes( aVar[ 3 ] ), ;
::GoUp() )
oBtn:bPainted := { || oBtn:SayText( aVar[ 2 ], { 8, nil, nil, -8 } , "TR" ) }
oBtn:bClrGrad := { |l,oBtn| If( oBtn:lMOver, {{ 1, RGB( 120,136,85 ), nRgb(255,255,255) }}, ;
If( oBtn:lPressed, RGB( 180,136,85 ), RGB( 120,136,85 ) ) ) }
return oBtn
function OnActionVariantes( c )
MsgInfo ( c )
return nil
#include "fivewin.ch"
REQUEST DBFCDX
static aVariantes := {}
static nFirstBtn := 0
function Main()
local oDlg, oFont, oBtnVariante[ 8 ], x, y, n
local cProduct := "0011"
OpenDBF()
SetProduct( cProduct )
DEFINE FONT oFont NAME "ARIAL" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 800,400 PIXEL FONT oFont
x := 10
y := 10
for n := 1 to 8
oBtnVariante[ n ] := CreateVarBtn( x, y, n, oDlg, oFont )
x += 50
if x > 160
x := 10
y += 35
endif
next
@ 10, 220 BTNBMP PROMPT "UP" FLAT SIZE 40,30 PIXEL OF oDlg ;
WHEN nFirstBtn >= 4 ;
ACTION ( nFirstBtn := Max( 0, nFirstBtn - 8 ), oDlg:Update() )
@ 45, 220 BTNBMP PROMPT "DOWN" FLAT SIZE 40,30 PIXEL OF oDlg ;
WHEN nFirstBtn + 8 < Len( aVariantes ) ;
ACTION ( nFirstBtn := Min( Len( aVariantes ) - 8, nFirstBtn + 8 ), ;
oDlg:Update() )
@ 10, 270 BTNBMP PROMPT "Change Product" FLAT SIZE 40,65 PIXEL OF oDlg ;
ACTION ( cProduct := SelectProduct(), SetProduct( cProduct ), oDlg:Update() )
// For changing product ACTION ( SetProduct( cNewProduct ), oDlgUpdate() )
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
static function SetProduct( cProduct )
local nLen
aVariantes := VA->( FW_DbfToArray( "ALLTRIM(DESC1),PRECIO,VARIANTE", { || FIELD->PRODUCTO = cProduct } ) )
nLen := Len( aVariantes )
ASize( aVariantes, Max( 8, 4 * Max( 1, Ceiling( nLen / 4 ) ) ) )
AFill( aVariantes, { "", "", "" }, nLen + 1 )
nFirstBtn := 0
return nil
static function OpenDBF()
USE PRODUC NEW SHARED ALIAS PR VIA "DBFCDX"
SET ORDER TO TAG PRODUC1
GO TOP
USE VARIANTI NEW SHARED ALIAS VA VIA "DBFCDX"
SET ORDER TO TAG VARIANT1
GO TOP
return nil
function CreateVarBtn( x, y, nBtn, oDlg, oFont )
local oBtn
@ y, x BTNBMP oBtn ;
PROMPT { || aVariantes[ nFirstBtn + nBtn, 1 ] } SIZE 48,30 PIXEL OF oDlg 2007 UPDATE ;
COLOR CLR_WHITE,RGB( 120,136,85 ) FONT oFont ;
WHEN !Empty( aVariantes[ nFirstBtn + nBtn, 1 ] ) ;
ACTION ( ::GoDown(), ;
OnActionVariantes( aVariantes[ nFirstBtn + nBtn, 3 ] ), ;
::GoUp() )
oBtn:bPainted := { || oBtn:SayText( cValToChar(aVariantes[ nFirstBtn + nBtn, 2 ]), { 8, nil, nil, -8 } , "TR" ) }
oBtn:bClrGrad := { |l,oBtn| If( oBtn:lMOver, {{ 1, RGB( 120,136,85 ), nRgb(255,255,255) }}, ;
If( oBtn:lPressed, RGB( 180,136,85 ), RGB( 120,136,85 ) ) ) }
oBtn:bClrGrad := { |l,oBtn| If( oBtn:lActive, If( oBtn:lMOver, {{ 1, RGB( 120,136,85 ), nRgb(255,255,255) }}, ;
If( oBtn:lPressed, RGB( 180,136,85 ), RGB( 120,136,85 ) ) ), CLR_GRAY ) }
oBtn:bClrGrad := < |u,oBtn|
local clr := CLR_GRAY
if oBtn:lActive
if oBtn:lMOver
clr := {{ 1, RGB( 120,136,85 ), nRgb(255,255,255) }}
elseif oBtn:lPressed
clr := RGB( 180,136,85 )
else
clr := RGB( 120,136,85 )
endif
endif
return clr
>
return oBtn
function OnActionVariantes( c )
MsgInfo ( c )
return nil
function SelectProduct()
local cRet := PR->PRODUCTO
XBROWSER "PR" SELECT cRet := PR->PRODUCTO
return cRet
Application
===========
Path and name: C:\Work\Errori\varianti_nages\nages.Exe (32 bits)
Size: 3,600,896 bytes
Compiler version: Harbour 3.2.0dev (r1406271520)
FiveWin version: FWH 17.02
C compiler version: Borland C++ 5.8.2 (32-bit)
Windows version: 6.1, Build 7600
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 06/04/17, 18:56:03
Error description: Error BASE/1132 Bound error: array access
Args:
[ 1] = A { ... } length: 4
[ 2] = N 5
Stack Calls
===========
Called from: nages.prg => (b)CREATEVARBTN( 82 )
Called from: .\source\classes\WINDOW.PRG => TDIALOG:AEVALWHEN( 2837 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:INITIATE( 714 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 898 )
Called from: => DIALOGBOXINDIRECT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 296 )
Called from: nages.prg => MAIN( 43 )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 44 guests