Code: Select all | Expand
// C:\ACUELAR\ACUELAR.PRG - ACUELAR.RES / ACUELAR.RC - 11/03/2024 - Joao.
#Include "FiveWin.ch"
#Include "DSay.Ch" // DYNAMIC SAY - EN C:\FWH..\INCLUDE
#Define CLR_ORANGE nRGB( 255, 165, 000 ) //-> Orange - Laranja
STATIC oTimer, oSayMens, oSayObrig, oSayGet
// By: Adhemar Cuéllar
FUNCTION Main()
LOCAL oDlg, oFnt, oFont, oBtn, cTitle, lCalcula := .F.
LOCAL oGet, cVar := 0.00, oActive, cActive, oIco
LOCAL oCursorBtn := TCursor():New(, 'HAND' )
cActive := SPACE(40)
SetBalloon( .t. )
SkinButtons()
cTitle := "FiveWin: Calculadora by Adhemar Cuéllar"
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 00, -14 BOLD
DEFINE FONT oFnt NAME "Ms Sans Serif" SIZE 00, -12 BOLD
DEFINE ICON oIco RESOURCE "ICONE01" // EN: ACUELAR.RC/.RES
// O:
// DEFINE ICON oIco RESOURCE "ICONE05" // EN: ACUELAR.RC/.RES, etc
DEFINE DIALOG oDlg FROM 0, 0 TO 400, 450 PIXEL FONT oFont TITLE cTitle ;
COLORS CLR_BLACK, CLR_WHITE TRANSPARENT ICON oIco
oDlg:lHelpIcon := .F.
IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
Set( _SET_INSERT, ! Set( _SET_INSERT ) )
ENDIF
@ 04, 15 SAY "<F7) Aciona Calculadora" SIZE 150, 12 OF oDlg UPDATE ;
PIXEL TRANSPARENT FONT oFont COLORS CLR_ORANGE, CLR_WHITE
@ 15, 15 GET oGet VAR cVar PICTURE "@E" BITMAP "CALC" UPDATE ;
SIZE 120, 12 OF oDlg PIXEL RIGHT // ACTION CALC( oDlg, oGet, @cVar )
oGet:lBtnTransparent := .T. // transparent button get oGet
oGet:lAdjustBtn := .T. // Button Get Adjust Witdh oGet
oGet:lDisColors := .F. // Deactive disable color
oGet:nClrTextDis := CLR_WHITE // Color text disable status
oGet:nClrPaneDis := CLR_BLUE // Color Pane disable status
oGet:bKeyDown := { |nKey| IF( nKey == VK_F7, Eval( oGet:bAction ), Nil ) }
@ 40, 15 SAY "Name/Nombre:" SIZE 100, 12 OF oDlg UPDATE ;
PIXEL TRANSPARENT FONT oFont COLORS CLR_HCYAN, CLR_WHITE
// cSayObrig := "* Field required/Obrigatorio" // example
cSayObrig := "* "
@ 40, 75 SAY oSayObrig VAR cSayObrig SIZE 100, 12 OF oDlg UPDATE ;
PIXEL TRANSPARENT FONT oFont COLORS CLR_ORANGE, CLR_WHITE
@ 55, 15 GET oActive VAR cActive PICTURE "@!" UPDATE SIZE 120, 12 OF oDlg ;
PIXEL VALID( ChkField( cActive, oActive ) )
@ 57, 12 SAY oSayGet VAR cSayObrig SIZE 100, 12 OF oDlg UPDATE ;
PIXEL TRANSPARENT FONT oFont COLORS CLR_HRED, CLR_WHITE
@ 135, 85 BTNBMP oBtn OF oDlg SIZE 40 , 50 PROMPT "&Exit" FONT oFont TOP ;
2007 RESOURCE "EXIT" ACTION( oDlg:End() )
oBtn:cTooltip := "Salida - Exit"
oBtn:lCancel := .T.
oBtn:lEllipse = .T.
oBtn:oCursor := oCursorBtn
// esconda/hide() todos os SAYS do seu dialogo Marcio.
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT( oSayObrig:Hide() )
IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
Set( _SET_INSERT, ! Set( _SET_INSERT ) )
ENDIF
oFnt:End()
oFont:End()
RETURN NIL
FUNCTION CHkField( cActive, oActive )
LOCAL Saying
LOCAL cSayObrig := "* Field required/Obrigatorio" // example
LOCAL cSayGet := "OH JUMENTO! Preencha o GET" // hahahaha melhor nao.
IF GETASYNCKEY( VK_UP ) // SETA PARA CIMA
RETURN( .T. )
ENDIF
IF cActive = " "
Saying := "Sorry... the Field ACTIVE is a Required field" + CRLF
Saying += "and Can Not be left BLANK"
// MsgInfo( Saying ) // se quiser mensagem, ligue Marcio.
// oActive:VARPUT( "Field ACTIVE is a Required" )
// oActive:Refresh()
oSayObrig:Show() // Ligue o SAY em tempo real
oSayObrig:VARPUT( cSayObrig )
oSayObrig:Refresh()
oActive:SetFocus()
RETURN( .F. )
ELSE
RETURN( .T. )
ENDIF
RETURN( .T. )
FUNCTION Calc( oDlg, oGet, cVar )
LOCAL oCalc := tCalc():new()
oCalc:calculadora( oDlg, '@E 9,999,999.9999', .F., oGet )
cVar := iif( !Empty( oCalc:nResult ), oCalc:nResult, cVar )
oGet :Refresh()
oCalc:End()
RETURN( .T. )
//
CLASS TCalc
DATA nResult
DATA aRolloCalc
DATA cUltima, cUltimaop
DATA cPatronSalida
METHOD New() CONSTRUCTOR
METHOD Init()
METHOD End()
METHOD nCalculadigual( nGet )
METHOD calculadora( oPadre, cPatronSalida, lBorraAlInicio )
METHOD TCalc_Teclas( nKey, oDlg )
METHOD Init( oGet, nKey )
ENDCLASS
// ----------------------------------------------------------------------------//
METHOD New() CLASS TCalc
::aRolloCalc := { { 'C', ' ' } }
::nResult := 0
::cUltima := ''
::cUltimaop := ''
RETURN SELF
// ----------------------------------------------------------------------------//
METHOD Init( oGet, nKey ) CLASS tCalc
LOCAL oCalc
IF nKey <> VK_F3
RETURN( 1 )
ENDIF
oCalc := tCalc():new()
oCalc:calculadora( oGet:oWnd, '@E 9,999,999.9999 ',, oGet )
RETURN( 0 )
// ----------------------------------------------------------------------------//
METHOD End() CLASS TCalc
::aRolloCalc := { { 'C', ' ' } }
::nResult := 0
::cUltima := ''
::cUltimaop := ''
RETURN NIL
// ----------------------------------------------------------------------------//
METHOD calculadora( oPadre, cPatronSalida, lBorraAlInicio, oTGet ) CLASS TCalc
LOCAL oDlg
LOCAL oBtnSalir, oBtnTrans
LOCAL oBtnmenos, oBtnmas, oBtnpor, oBtndividir, oBtnigual, oBtnBorra
LOCAL oBtn0, oBtn1, oBtn2, oBtn3, oBtn4, oBtn5, oBtn6, oBtn7, oBtn8, ;
oBtn9, oBtnP, oBtnSigno
LOCAL oBtnConv, oBtnConv2
LOCAL oBtnDel
LOCAL oSay, cMens
LOCAL oBrw, n := 1
LOCAL oGet := 0, cGet := '', nGetAnt := 0, nGet := 0
LOCAL oFont
LOCAL oFont1
LOCAL oFontLst
::nResult := iif( ValType( oTGet ) == "O" .AND. "GET" $ oTGet:ClassName .AND. ;
Val( oTGet:GetText() ) > 0, Val( oTGet:GetText() ), ;
iif( ValType( oTGet ) == "N", oTGet, 0 ) )
IF cPatronSalida = NIL .AND. ::cPatronSalida = NIL
cPatronSalida := '@E 9,999,999,999.99 '
ENDIF
DEFAULT lBorraAlInicio := .F.
::cPatronSalida := cPatronSalida
cMens := "FiveWin: Calculadora by Adhemar Cuéllar"
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, - 14 BOLD
DEFINE FONT oFont1 NAME "Arial" SIZE 0, - 20
DEFINE FONT oFontLst NAME "MS Sans Serif" SIZE 0, - 14
DEFINE DIALOG oDlg RESOURCE 'Calculadora' OF oPadre FONT oFont ;
COLORS CLR_BLACK, CLR_WHITE TRANSPARENT
oDlg:lHelpIcon := .F.
REDEFINE SAY ID 420 OF oDlg COLOR CLR_ORANGE, CLR_WHITE UPDATE FONT oFont TRANSPARENT
// DEFINE TIMER oTimer INTERVAL 1000 ACTION Blinker( oSay, oTimer )
// https://forums.fivetechsupport.com/viewtopic.php?f=3&t=43239
// BLINKER - ASI, NO ME GUSTA - PREFIRO DYNAMIC SAY - DSAY.PRG
REDEFINE SAY oSayMens VAR cMens ID 450 OF oDlg UPDATE ;
COLOR CLR_ORANGE, CLR_WHITE FONT oFont1 TRANSPARENT
// USANDO DYNAMIC SAY - MUCHO MEJOR.
REDEFINE DYNAMIC SAY PROMPT cMens ID 460 OF oDlg CENTER BLINKING UPDATE ;
COLOR CLR_ORANGE, CLR_WHITE FONT oFont1 TRANSPARENT
REDEFINE BUTTON oBtnTrans ID 112 OF oDlg MESSAGE 'Lleva el resultado para o campo numérico.';
ACTION oDlg:End() CANCEL // UPDATE
oBtnTrans:Cargo := "L"
REDEFINE BUTTON oBtnSalir ID 500 OF oDlg MESSAGE 'Cancela/Salida';
ACTION (::nResult:=0,oDlg:End()) CANCEL
oBtnSalir:Cargo := "S"
REDEFINE BUTTON oBtnmenos ID 401 OF oDlg MESSAGE 'Resta';
ACTION ( iif( nGet <> 0, ( nGetAnt := nGet, AAdd( ::aRolloCalc, { Transform( nGet, ::cPatronSalida ), '-' } ) ), ( ::nResult := ::nResult - nGetAnt, AAdd( ::aRolloCalc, { Transform( iif( ::cUltimaOp = '=', ::nResult, nGetAnt ), ::cPatronSalida ), '-' } ) ) ), ;
oBrw:gobottom(), ;
oBrw:refresh(), ;
iif( ::nResult = 0, ::nResult := nGet, ::nResult := ::nResult - nGet ), ;
::cUltimaOp := '-', ;
oSay:SetText( Transform( ::nResult, ::cPatronSalida ) ), ;
nGet := 0, ;
cGet := '', ;
oGet:SetText( '' ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtnmenos:Cargo := '-'
REDEFINE BUTTON oBtnmas ID 402 OF oDlg MESSAGE 'Suma';
ACTION ( iif( nGet <> 0, ( nGetAnt := nGet, AAdd( ::aRolloCalc, { Transform( nGet, ::cPatronSalida ), '+' } ) ), ( ::nResult := ::nResult + nGetAnt, AAdd( ::aRolloCalc, { Transform( iif( ::cUltimaOp = '=', ::nResult, nGetAnt ), ::cPatronSalida ), '+' } ) ) ), ;
oBrw:gobottom(), ;
oBrw:refresh(), ;
iif( ::nResult = 0, ::nResult := nGet, ::nResult := ::nResult + nGet ), ;
::cUltimaOp := '+', ;
oSay:SetText( Transform( ::nResult, ::cPatronSalida ) ), ;
nGet := 0, ;
cGet := '', ;
oGet:SetText( '' ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtnmas:Cargo := '+'
REDEFINE BUTTON oBtnpor ID 403 OF oDlg MESSAGE 'Multiplica';
ACTION ( AAdd( ::aRolloCalc, iif( nGet = 0 .AND. ::nResult <> 0, { Transform( ::nResult, ::cPatronSalida ), 'x' }, { Transform( nGet, ::cPatronSalida ), 'x' } ) ), ;
oBrw:gobottom(), ;
oBrw:refresh(), ;
iif( ::nResult = 0, ::nResult := nGet, iif( nGet <> 0, ::nResult := ::nResult * nGet, ) ), ;
::cUltimaOp := '*', ;
oSay:SetText( Transform( ::nResult, ::cPatronSalida ) ), ;
nGet := 0, ;
cGet := '', ;
oGet:SetText( '' ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtnpor:Cargo := '*'
REDEFINE BUTTON oBtndividir ID 404 OF oDlg MESSAGE 'Divide';
ACTION ( AAdd( ::aRolloCalc, iif( nGet = 0 .AND. ::nResult <> 0, { Transform( ::nResult, ::cPatronSalida ), '/' }, { Transform( nGet, ::cPatronSalida ), '/' } ) ), ;
oBrw:gobottom(), ;
oBrw:refresh(), ;
iif( ::nResult = 0, ::nResult := nGet, iif( nGet <> 0, ::nResult := ::nResult / nGet, ) ), ;
::cUltimaOp := '/', ;
oSay:SetText( Transform( ::nResult, ::cPatronSalida ) ), ;
nGet := 0, ;
cGet := '', ;
oGet:SetText( '' ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtndividir:Cargo := '/'
REDEFINE BUTTON oBtnigual ID 405 OF oDlg MESSAGE 'Calcula resultado';
ACTION ( iif( nGet = 0,, AAdd( ::aRolloCalc, { Transform( nGet, ::cPatronSalida ), iif( ::cUltimaOp = '+' .OR. ::cUltimaOp = '-' .OR. ::cUltimaOp = '*' .OR. ::cUltimaOp = '/', ' ', ::cUltimaOp ) } ) ), ;
::nCalculadIgual( nGet ), ;
AAdd( ::aRolloCalc, { Transform( ::nResult, ::cPatronSalida ), '=' } ), ;
oBrw:gobottom(), oBrw:gobottom(), ;
oBrw:refresh(), ;
::cUltimaOp := '=', ;
oSay:SetText( Transform( ::nResult, ::cPatronSalida ) ), ;
nGet := 0, ;
nGetAnt := 0, ;
cGet := '', ;
oGet:SetText( '' ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtnigual:Cargo := '='
REDEFINE BUTTON oBtnBorra ID 425 OF oDlg MESSAGE 'Borra todos los cálculos';
ACTION ( iif( Len( ::aRolloCalc ) > 0, ;
( ASize( ::aRolloCalc, 0 ), oBrw:Refresh() ), ), ;
AAdd( ::aRolloCalc, { ' ', 'C' } ), ;
oBrw:gotop(), ;
oBrw:refresh(), ;
::nResult := 0, ;
::cUltimaOp := 'R', ;
oSay:SetText( '0' ), ;
nGet := 0, ;
cGet := '', ;
oGet:SetText( '' ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtnBorra:Cargo := 'R'
REDEFINE BUTTON oBtnDel ID 426 OF oDlg MESSAGE 'Borra último dígito';
ACTION ( ::cUltima := 'CE', ;
iif( ::cUltimaOp = '=' .OR. ::cUltimaOp = 'AP' .OR. ::cUltimaOp = 'AE', ( ::cUltimaOp := '', ::nResult := 0, AAdd( ::aRolloCalc, { ' ', ' ' } ), oBrw:gobottom(), oBrw:refresh() ), ), ;
iif( nGet <> 0, ( cGet := Left( cGet, Len( cget ) - 1 ), nGet := Val( cGet ) ), ), ;
oGet:SetText( cGet ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtnDel:Cargo := Chr( 8 )
REDEFINE BUTTON oBtn0 ID 100 OF oDlg;
ACTION ( ::cUltima := '0', ;
iif( ::cUltimaOp = '=' .OR. ::cUltimaOp = 'AP' .OR. ::cUltimaOp = 'AE', ( ::cUltimaOp := '', ::nResult := 0, AAdd( ::aRolloCalc, { ' ', ' ' } ), oBrw:gobottom(), oBrw:refresh() ), ), ;
cGet := cGet + ::cUltima, ;
nGet := Val( cGet ), ;
oGet:SetText( cGet ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtn0:Cargo := '0'
REDEFINE BUTTON oBtn1 ID 101 OF oDlg;
ACTION ( ::cUltima := '1', ;
iif( ::cUltimaOp = '=' .OR. ::cUltimaOp = 'AP' .OR. ::cUltimaOp = 'AE', ( ::cUltimaOp := '', ::nResult := 0, AAdd( ::aRolloCalc, { ' ', ' ' } ), oBrw:gobottom(), oBrw:refresh() ), ), ;
cGet := cGet + ::cUltima, ;
nGet := Val( cGet ), ;
oGet:SetText( cGet ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtn1:Cargo := '1'
REDEFINE BUTTON oBtn2 ID 102 OF oDlg;
ACTION ( ::cUltima := '2', ;
iif( ::cUltimaOp = '=' .OR. ::cUltimaOp = 'AP' .OR. ::cUltimaOp = 'AE', ( ::cUltimaOp := '', ::nResult := 0, AAdd( ::aRolloCalc, { ' ', ' ' } ), oBrw:gobottom(), oBrw:refresh() ), ), ;
cGet := cGet + ::cUltima, ;
nGet := Val( cGet ), ;
oGet:SetText( cGet ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtn2:Cargo := '2'
REDEFINE BUTTON oBtn3 ID 103 OF oDlg;
ACTION ( ::cUltima := '3', ;
iif( ::cUltimaOp = '=' .OR. ::cUltimaOp = 'AP' .OR. ::cUltimaOp = 'AE', ( ::cUltimaOp := '', ::nResult := 0, AAdd( ::aRolloCalc, { ' ', ' ' } ), oBrw:gobottom(), oBrw:refresh() ), ), ;
cGet := cGet + ::cUltima, ;
nGet := Val( cGet ), ;
oGet:SetText( cGet ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtn3:Cargo := '3'
REDEFINE BUTTON oBtn4 ID 104 OF oDlg;
ACTION ( ::cUltima := '4', ;
iif( ::cUltimaOp = '=' .OR. ::cUltimaOp = 'AP' .OR. ::cUltimaOp = 'AE', ( ::cUltimaOp := '', ::nResult := 0, AAdd( ::aRolloCalc, { ' ', ' ' } ), oBrw:gobottom(), oBrw:refresh() ), ), ;
cGet := cGet + ::cUltima, ;
nGet := Val( cGet ), ;
oGet:SetText( cGet ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtn4:Cargo := '4'
REDEFINE BUTTON oBtn5 ID 105 OF oDlg;
ACTION ( ::cUltima := '5', ;
iif( ::cUltimaOp = '=' .OR. ::cUltimaOp = 'AP' .OR. ::cUltimaOp = 'AE', ( ::cUltimaOp := '', ::nResult := 0, AAdd( ::aRolloCalc, { ' ', ' ' } ), oBrw:gobottom(), oBrw:refresh() ), ), ;
cGet := cGet + ::cUltima, ;
nGet := Val( cGet ), ;
oGet:SetText( cGet ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtn5:Cargo := '5'
REDEFINE BUTTON oBtn6 ID 106 OF oDlg;
ACTION ( ::cUltima := '6', ;
iif( ::cUltimaOp = '=' .OR. ::cUltimaOp = 'AP' .OR. ::cUltimaOp = 'AE', ( ::cUltimaOp := '', ::nResult := 0, AAdd( ::aRolloCalc, { ' ', ' ' } ), oBrw:gobottom(), oBrw:refresh() ), ), ;
cGet := cGet + ::cUltima, ;
nGet := Val( cGet ), ;
oGet:SetText( cGet ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtn6:Cargo := '6'
REDEFINE BUTTON oBtn7 ID 107 OF oDlg;
ACTION ( ::cUltima := '7', ;
iif( ::cUltimaOp = '=' .OR. ::cUltimaOp = 'AP' .OR. ::cUltimaOp = 'AE', ( ::cUltimaOp := '', ::nResult := 0, AAdd( ::aRolloCalc, { ' ', ' ' } ), oBrw:gobottom(), oBrw:refresh() ), ), ;
cGet := cGet + ::cUltima, ;
nGet := Val( cGet ), ;
oGet:SetText( cGet ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtn7:Cargo := '7'
REDEFINE BUTTON oBtn8 ID 108 OF oDlg;
ACTION ( ::cUltima := '8', ;
iif( ::cUltimaOp = '=' .OR. ::cUltimaOp = 'AP' .OR. ::cUltimaOp = 'AE', ( ::cUltimaOp := '', ::nResult := 0, AAdd( ::aRolloCalc, { ' ', ' ' } ), oBrw:gobottom(), oBrw:refresh() ), ), ;
cGet := cGet + ::cUltima, ;
nGet := Val( cGet ), ;
oGet:SetText( cGet ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtn8:Cargo := '8'
REDEFINE BUTTON oBtn9 ID 109 OF oDlg;
ACTION ( ::cUltima := '9', ;
iif( ::cUltimaOp = '=' .OR. ::cUltimaOp = 'AP' .OR. ::cUltimaOp = 'AE', ( ::cUltimaOp := '', ::nResult := 0, AAdd( ::aRolloCalc, { ' ', ' ' } ), oBrw:gobottom(), oBrw:refresh() ), ), ;
cGet := cGet + ::cUltima, ;
nGet := Val( cGet ), ;
oGet:SetText( cGet ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtn9:Cargo := '9'
REDEFINE BUTTON oBtnP ID 110 OF oDlg;
ACTION ( ::cUltima := '.', ;
iif( ::cUltimaOp = '=' .OR. ::cUltimaOp = 'AP' .OR. ::cUltimaOp = 'AE', ( ::cUltimaOp := '', ::nResult := 0, AAdd( ::aRolloCalc, { ' ', ' ' } ), oBrw:gobottom(), oBrw:refresh() ), ), ;
cGet := cGet + ::cUltima, ;
nGet := Val( cGet ), ;
oGet:SetText( cGet ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE WHEN Int( nGet ) == nGet
oBtnP:Cargo := '.'
REDEFINE BUTTON oBtnSigno ID 111 OF oDlg;
ACTION ( ::cUltima := 'signo', ;
iif( ::cUltimaOp = '=' .OR. ::cUltimaOp = 'AP' .OR. ::cUltimaOp = 'AE', ( ::cUltimaOp := '', ::nResult := 0, AAdd( ::aRolloCalc, { ' ', ' ' } ), oBrw:gobottom(), oBrw:refresh() ), ), ;
nGet := ( - 1 ) * nGet, ;
oGet:SetText( nGet ), ;
cGet := AllTrim( Str( nGet ) ), ;
oBtnIgual:Setfocus(), ;
sysrefresh() ) UPDATE
oBtnSigno:Cargo := ' '
REDEFINE SAY oGet VAR nGet ID 211 OF oDlg FONT oFont1 ;
COLOR nrgb( 0, 0, 0 ), nrgb( 255, 255, 200 ) UPDATE
REDEFINE SAY oSay VAR ::nResult ID 200 OF oDlg FONT oFont1 ;
COLOR nrgb( 50, 250, 50 ), nrgb( 0, 0, 0 ) UPDATE
REDEFINE LISTBOX oBrw FIELDS ;
::aRolloCalc[ n ][ 1 ], ;
::aRolloCalc[ n ][ 2 ] ;
HEAD 'Valor', 'Op';
ID 212 OF oDlg FONT oFontLst COLOR nrgb( 0, 0, 0 ), nrgb( 255, 255, 200 ) ;// clrLtrBrow,clrFonBrow ;
UPDATE
oBrw:aJustify := { .T., .F. }
oBrw:aColSizes := { GetFontInfo( oFontLst )[ 2 ] * 1.25 * 17, GetFontInfo( oFontLst )[ 2 ] * 1.25 * 3 } // aMatrizTc({17,3},oFontLst)
oBrw:bGotop := {|| n := 1 }
oBrw:bGoBottom := {|| n := Eval( oBrw:bLogicLen ) }
oBrw:bSkip := {| nwant, nold | nold := n, n += nwant, ;
n := Max( 1, Min( n, Eval( oBrw:bLogicLen ) ) ), ;
n - nOld }
oBrw:bLogicLen := {|| Len( ::aRolloCalc ) }
oBrw:nClrPane := {|| iif( ::aRolloCalc[ n ][ 2 ] == '=', nrgb( 200, 255, 125 ), nrgb( 255, 255, 200 ) ) }
oDlg:bKeyDown := {| nKey | ::TCalc_Teclas( nKey, oDlg, oTget ) }
ACTIVATE DIALOG oDlg ;
ON INIT ( if( lBorraAlInicio, oBtnBorra:CLICK(), .F. ), ;
oBrw:gobottom(), oBrw:refresh(), TIMER( oDlg, oSayMens ) )
oFont:End()
oFont1:End()
oFontLst:End()
RETURN ::nResult
//
METHOD nCalculadigual( nGet ) CLASS TCalc
DO CASE
CASE ::cUltimaOp = '-'
::nResult := ::nResult - nGet
CASE ::cUltimaOp = '+'
::nResult := ::nResult + nGet
CASE ::cUltimaOp = '*'
::nResult := ::nResult * nGet
CASE ::cUltimaOp = '/'
::nResult := ::nResult / nGet
ENDCASE
RETURN NIL
//
METHOD TCalc_Teclas( nKey, oDlg, oTGet ) CLASS TCalc
LOCAL ny
FOR ny := 1 TO Len( oDlg:aControls )
IF oDlg:aControls[ ny ]:Cargo == Upper( Chr( nKey ) )
oDlg:aControls[ ny ]:CLICK()
ENDIF
NEXT ny
IF nKey == 84 .AND. ValType( oTGet ) == "O"
oDlg:End()
oTGet:VarPut( ::nResult )
oTGet:Refresh()
ENDIF
RETURN NIL
FUNCTION Timer( oDlg, oSayMens )
Static lOn := .f.
DEFINE TIMER oTimer INTERVAL 1000 OF oDlg ;
ACTION ( oSayMens:VarPut( "BLINKER: " + DTOC(DATE())+" - " + ;
TIME() ), oSayMens:Refresh() )
ACTIVATE TIMER oTimer
oTimer:DeActivate()
if lOn
oSayMens:Enable() // Hide()
else
oSayMens:Disable() // Show()
endif
lOn := !lOn
oTimer:Activate()
oDlg:Refresh()
RETURN NIL
/*
//-----------------------------------------------------------------------
FUNCTION Blinker( oCtrl, oTimer )
Static lOn := .f.
oTimer:DeActivate()
if lOn
oCtrl:Enable() //Hide()
else
oCtrl:Disable() //Show()
endif
lOn := !lOn
oTimer:Activate()
RETURN NIL
*/
// FIN / END
Regards, saludos.