maestro, que error és este?
viewtopic.php?f=17&t=3961
Gracias, saludos.
/*
=================================================================================
GetCalc.prg - PopUp-Calculator (c) copyright: Timm Sodtalbers, 2003
info@reportdesigner.info
www.reportdesigner.info
---------------------------------------------------------------------------------
In order to activate the PopUp-Calculator when pressing the space key in numeric
fields just add this lines in the KeyDown method of the tGet class:
case nKey == VK_SPACE .AND. ::oGet:Type == "N"
ShowCalculator( SELF )
or if you only want to use the calculator with certain get fields:
oGet:bKeyDown = {|nKey| IIF( nKey == VK_SPACE, ShowCalculator( oGet ), .T. ) }
History:
24.6.2003 - if the get field is <> 0 its value will be copied into the calculator
22.6.2003 - first release
=================================================================================
*/
#INCLUDE "FiveWin.ch"
#DEFINE SC_TITLE " Fórmula:"
#DEFINE SC_ERROR1 "El resultado no cabe dentro del campo."
#DEFINE SC_ERROR2 "El valor es incorrecto."
#DEFINE SC_ERROR3 "valor incorrecto"
#DEFINE SC_STOP "A T E N C I Ó N"
function Main()
LOCAL oDlg, oGet, oGet2
LOCAL cCad := "Testing " // pad("Testing Gets",40)
LOCAL nNum := 0
LOCAL dDat := Date()
Set century On
Set Date Ansi
Set Date format "mm/dd/yyyy"
SET _3DLOOK ON
DEFINE DIALOG oDlg TITLE "TGet from " + FWDESCRIPTION
@ 1, 2 SAY "Text..:" OF oDlg
@ 1, 6 GET oGet VAR cCad OF oDlg SIZE 60, 10 COLOR "W/G" PICTURE "@K"
@ 1.8, 2 SAY "Number:" OF oDlg
@ 2, 6 GET oGet2 VAR nNum OF oDlg SIZE 60, 10 PICTURE "9,999,999.99"
oGet2:bKeyDown = {|nKey| IIF( nKey == VK_SPACE, ShowCalculator( oGet2 ), .T. ) }
@ 2.6, 2 SAY "Date:" OF oDlg
@ 3, 6 GET oGet VAR dDat PICTURE "@E" OF oDlg SIZE 60, 10 // "@D"
@ 3, 7 BUTTON "&Ok" OF oDlg SIZE 30, 12 ACTION oDlg:End()
@ 3, 16 BUTTON "&Cancel" SIZE 30, 12 OF oDlg ACTION oDlg:End() CANCEL
// TGet():SetColorFocus( nRGB( 200, 120, 120 ) )
ACTIVATE DIALOG oDlg CENTERED
return nil
*-- FUNCTION -----------------------------------------------------------------
* Name: ShowCalculator
* Description:
* Author: Timm Sodtalbers
*-----------------------------------------------------------------------------
FUNCTION ShowCalculator( oCurGet )
LOCAL oDlg, oBtn, oGet1, oSay1, aResult
LOCAL lTake := .F.
LOCAL cBuffer := oCurGet:oGet:Buffer
LOCAL nHorzRes := GetSysMetrics( 0 )
LOCAL oGetRect := oCurGet:GetRect()
LOCAL nTop := oGetRect:nTop - 62
LOCAL nLeft := IIF( oGetRect:nRight + 126 > nHorzRes, nHorzRes - 212, oGetRect:nLeft )
LOCAL nDezimal := IIF( oCurGet:oGet:DecPos = -1 , ;
0, LEN( oCurGet:oGet:Buffer ) - oCurGet:oGet:DecPos )
LOCAL cFormula := IIF( VAL( cBuffer ) = 0, "", ALLTRIM( cBuffer ) ) + SPACE( 200 )
DEFINE DIALOG oDlg FROM 0, 0 TO 26, 200 PIXEL STYLE nOr( DS_MODALFRAME, WS_POPUP )
@ 0, 0 SAY SC_TITLE OF oDlg SIZE 300, 7 PIXEL COLOR CLR_WHITE, RGB( 9, 104, 168 )
@ 9, 2 GET oGet1 VAR cFormula OF oDlg SIZE 98, 10 PIXEL PICTURE "@S100"
IF .NOT. EMPTY( cBuffer )
oGet1:SetPos( LEN(ALLTRIM( cFormula )) + 1 )
ENDIF
oGet1:bChange := {|| SC_Result( SC_FormulaString( oGet1 ), nDezimal, cBuffer, oSay1 ) }
@ 21, 2 SAY oSay1 PROMPT ALLTRIM( cFormula ) OF oDlg SIZE 98, 8 PIXEL COLOR CLR_GRAY RIGHT
#IFDEF __HARBOUR__
oGet1:bKeyDown = {|nKey,nFlags| ;
IIF( nKey == VK_RETURN, ( oGet1:bChange := {|| .T. }, lTake := .T., oDlg:End() ), ) }
#ELSE
@ 9, 120 BUTTON oBtn PROMPT "..." OF oDlg SIZE 10, 10 PIXEL ACTION oDlg:End()
oBtn:bGotFocus = {|| lTake := .T., oDlg:End() }
#ENDIF
ACTIVATE DIALOG oDlg ;
ON INIT oDlg:Move( nTop, nLeft, 210, 62 )
IF lTake = .T. .AND. .NOT. EMPTY( cFormula ) .AND. oCurGet:lFocused = .T.
aResult := SC_Result( cFormula, nDezimal, cBuffer )
IF EMPTY( aResult[2] )
oCurGet:VarPut( aResult[1] )
oCurGet:Refresh()
ELSE
MsgStop( aResult[2], SC_STOP )
ENDIF
ENDIF
RETURN (.T.)
*-- FUNCTION -----------------------------------------------------------------
* Name: SC_Result
* Description:
* Author: Timm Sodtalbers
*-----------------------------------------------------------------------------
FUNCTION SC_Result( cFormula, nDezimal, cBuffer, oSay )
LOCAL nValue
LOCAL cError := ""
cFormula := STRTRAN( cFormula, ",", "." )
IF TYPE( cFormula ) = "N"
nValue := &( cFormula )
IF LEN( cBuffer ) < LEN( ALLTRIM( STR( nValue, 100, nDezimal ) ) )
cError := SC_ERROR1
ENDIF
ELSE
cError := SC_ERROR2
ENDIF
IF oSay <> NIL
oSay:SetText( IIF( EMPTY( cError), ALLTRIM(STR( nValue, 100, nDezimal )), SC_ERROR3 ) )
ENDIF
RETURN { nValue, cError }
*-- FUNCTION------------------------------------------------------------------
* Name: SC_FormulaString
* Description:
* Author: Timm Sodtalbers
*-----------------------------------------------------------------------------
FUNCTION SC_FormulaString( oGet )
LOCAL cBuffer := ALLTRIM( oGet:oGet:buffer )
LOCAL nLastKey := oGet:nLastKey
IF nLastKey > 96 .AND. nLastKey < 116
nLastKey := nLastKey - 96 + 48
ENDIF
/*
IF nLastKey <> 8
cBuffer := STUFF( cBuffer, oGet:nPos, 0, CHR( nLastKey ) )
ENDIF
*/
RETURN ( cBuffer )
REDEFINE GET oGet[4] VAR aDatos[ _PRECIO ] ID 203 OF oDlg;
PICTURE "@E 999,999.99";
BITMAP ovarsis:BitMap[ BMP_GETCALC ];
ACTION ( ShowCalculator(oGet[4]) )
Called from: .\source\classes\TGET.PRG => (b)TGET_CREATEBUTTON( 487 )
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 37 guests