FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Calculadora Calculator
Posts: 133
Joined: Fri Nov 30, 2007 11:34 AM
Re: Calculadora Calculator
Posted: Tue Jan 11, 2011 11:53 AM
Buenos días.

He logrado compilar y enlazar con mi programa. He quitado la coma en las dos líneas de TCALC, (188 y 227). Queda así la 188:

REDEFINE BUTTON oBtnDel ID 426 OF oDlg MESSAGE 'Borra último dígito';
ACTION (::='CE' ,;
iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::=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

Como verás falta una "," en la línea iif(nGet<>0,( ; delante del punto y coma.

Para llamar la aplicación he modificado la línea en el programa principal para trabajar con 2 decimales.

setkey(VK_F12, {|| oCalc:calculadora(oWnd,'@E 9,999,999.99 ')})


Espero haber contribuido en algo. Un saludo. Fernando
Saludos. Fernando
Posts: 563
Joined: Sun Oct 09, 2005 07:23 PM
Re: Calculadora Calculator
Posted: Tue Jan 11, 2011 04:44 PM

Ahí va el link en MediaFire

http://www.mediafire.com/?j0k2t4idt0ckaw4

Como esto sigue usándose después de cuatro años desde su publicación tal vez lo podría Antonio meter en la carpeta de utilidades para que permaneciera siempre allí.

Saludos.

Posts: 400
Joined: Tue Oct 16, 2007 05:51 PM
Re: Calculadora Calculator
Posted: Sat Jan 15, 2011 08:26 PM

Parece que el enlace para bajar el archivo esta roto, o el archivo fue borrado..

Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
Posts: 563
Joined: Sun Oct 09, 2005 07:23 PM
Re: Calculadora Calculator
Posted: Mon Jan 17, 2011 01:23 PM

Acabo de comprobar el link y está correcto.

Posts: 257
Joined: Tue May 16, 2006 04:46 PM
Re: Calculadora Calculator
Posted: Wed Mar 09, 2011 06:07 PM

Hace algun tiempo baje la Calculadora de Verhoven y fue la version del 23/09/2007.

Sabe alguien si hay alguna version mas reciente?

RodolfoRBG
FWH 1307, xHarbour123 BCC582
rodolfoerbg@gmail.com
Posts: 563
Joined: Sun Oct 09, 2005 07:23 PM
Re: Calculadora Calculator
Posted: Thu Mar 10, 2011 09:25 AM

No la he vuelto a tocar desde la última versión que dejé colgada en un mensaje anterior.
Saludos.

Posts: 880
Joined: Fri Jan 12, 2007 08:35 PM
Re: Calculadora Calculator
Posted: Thu Mar 10, 2011 03:41 PM

HOLA MUCHAS GRACIAS :D

Que lindo en compartir pero que ya borraron el archivito de aqui http://www.mediafire.com/?a5px22pjtx5 :shock:

Saluditos :wink:

Que es mejor que programar? creo que nada :)
Atropellada pero aqui ando :P

I love Fivewin

séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: Calculadora Calculator
Posted: Thu Mar 10, 2011 04:03 PM

Saludos, parece que a Mediafire no le gusta FW, el link dice que esta borrado el archivo, si lo pueden subir de nuevo o a otro servidor. El 4shared es bueno y rapido...

Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Calculadora Calculator
Posted: Thu Mar 10, 2011 05:16 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: Calculadora Calculator
Posted: Thu Mar 10, 2011 06:29 PM

Muy bonita... Te felicito a ti y a Sergio

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 563
Joined: Sun Oct 09, 2005 07:23 PM
Re: Calculadora Calculator
Posted: Fri Mar 11, 2011 07:08 AM

Dejo nuevamente el original, más espartano, pero el original al fin y al cabo.

http://www.mediafire.com/?av1y6bbybi7quze

En la vistosa última modificación que han dejado me ha parecido que el scroll de las operaciones no funciona bien y que para obtener el resultado hay que utilizar el ratón pulsando el igual en vez de bastar con darle a intro. La idea original era poder efectuar las operaciones sin uso de ratón.

Saludos.

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Calculadora Calculator
Posted: Fri Mar 11, 2011 12:09 PM
Verhoven wrote:Dejo nuevamente el original, más espartano, pero el original al fin y al cabo.

http://www.mediafire.com/?av1y6bbybi7quze

En la vistosa última modificación que han dejado me ha parecido que el scroll de las operaciones no funciona bien y que para obtener el resultado hay que utilizar el ratón pulsando el igual en vez de bastar con darle a intro. La idea original era poder efectuar las operaciones sin uso de ratón.

Saludos.



Gracias a los 2. Excelente calculadora.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 537
Joined: Mon Jan 16, 2006 03:42 PM
Re: Calculadora Calculator
Posted: Sat Oct 24, 2020 09:33 PM

Hola colegas, consulta Algun colega que tenga esta calculadora

saludos

Posts: 563
Joined: Sun Oct 09, 2005 07:23 PM
Re: Calculadora Calculator
Posted: Tue Oct 27, 2020 03:15 PM
Buenas tardes,
Adjunto el código original de la clase para que la puedan seguir disfrutando:
Code (fw): Select all Collapse
/*
  TCALC.PRG   
  CLASE QUE PERMITE PONER UNA CALCULADORA CON ROLLO DE PAPEL VIRTUAL.
  Necesita el fichero de recursos: calculadora.RC

  Primera Versión: Junio del 2007 DC
  Ultima Revisión: 25/03/2015
  Adaptación a XBROWSE: 25/03/2015
  Autor: Verhoven.  ¡ Seguro les resultará de utilidad !
         1.- Queda autorizado su libre distribucion y uso, incluso con fines comerciales . 
         2.- El autor declina cualquier responsabilidad en caso de funcionamiento anómalo.

  Ejemplo: Hacemos una calculadora que se active pulsando F12:
           Para incluirla en un programa basta con poner después de la función main() del mismo.
           #include 'TCALC.PRG'
           public oCalc:=tCalc():new()
           setkey(VK_F12, {|| oCalc:calculadora(oWnd,'@E 9,999,999.9999 ')})
  
  Vea el significado de las variables de instancia y de las que se les pasan a los métodos para 
   aprovechar algunas posibilidades de configuración.
*/

#include "fivewin.ch"
#include "XBrowse.Ch"

CLASS TCalc
 DATA nResult             //Resultado de las operaciones en curso.    
 DATA aRolloCalc          //Operaciones realizadas desde la última vez que se borró todo.
 
 DATA cUltima, cUltimaop      
 DATA cPatronSalida       // cPatronSalida  -> Formato en que se pinta el resultado.    
    
 METHOD New() CONSTRUCTOR
 
 METHOD End()
     
 METHOD nCalculadigual(nGet)
     
 METHOD calculadora(oPadre,cPatronSalida,lBorraAlInicio)
                    // lBorraAlInicio -> Al llamar al método si está en .t. borra lo que hubiera.
                    //                    Si está en .f. ó NIL conserva las operaciones anteriores.
     
 METHOD TCalc_Teclas(nKey, oDlg)
ENDCLASS

//----------------------------------------------------------------------------//

METHOD New() CLASS TCalc
 ::aRolloCalc:={{'C',' '}}   
 ::nResult   :=0             
 
 ::cUltima   :=''
 ::cUltimaop :=''     
return SELF

//----------------------------------------------------------------------------//

METHOD End() CLASS TCalc
 ::aRolloCalc:={{'C',' '}}
 ::nResult   :=0

 ::cUltima   :=''
 ::cUltimaop :='' 
return NIL

//----------------------------------------------------------------------------//

METHOD calculadora(oPadre,cPatronSalida,lBorraAlInicio) CLASS TCalc
local oDlg
local oBtnSalir
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
local oBrw, n:=1
local oGet, nGet:=0 ,cGet:='', nGetAnt:=0
local oFont1
local oFontLst

if cPatronSalida=NIL .AND. ::cPatronSalida=NIL
   cPatronSalida:='@E 9,999,999,999.99 '  //Formato en que se pinta el resultado.
endif

//default cPatronSalida:='@E 9,999,999,999.99 '  //Formato en que se pinta el resultado.
default lBorraAlInicio :=.f.  // Al llamar al método si está en .t. borra lo que hubiera.
                              //  Si está en .f. entonces conserva las operaciones anteriores.

::cPatronSalida:=cPatronSalida

    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 TITLE 'CALCULADORA' FONT oFont

    REDEFINE BUTTON oBtnSalir ID 500 OF oDlg MESSAGE 'SALIR';
             ACTION oDlg:end() default CANCEL UPDATE
             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,NIL)),;
                     ::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,NIL)),;
                     ::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() ),NIL ),;
                     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 (::='CE'            ,;
                     iif(::cUltimaOp='=' .OR. ::cUltimaOp='AP' .OR. ::cUltimaOp='AE',(::cUltimaOp:='',::=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),NIL),;
                     iif(nGet<>0,(              ,;
                     cGet:=LEFT(cGet,len(cget)-1),;
                     nGet:=val(cGet)),NIL)       ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtnDel:=chr(8)
*/
    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()),NIL),;
                     iif(nGet<>0,(cGet:=LEFT(cGet,len(cget)-1),nGet:=val(cGet)),NIL),;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtnDel:cargo:=chr(8)
             
    REDEFINE BUTTON oBtnConv ID 407 OF oDlg MESSAGE 'Convierte de euros a PTS';
             ACTION ( iif(nGet<>0,::nResult:=round(nGet*166.386,0),::nResult:=round(::nResult*166.386,0)),;
                     aadd( ::aRolloCalc, {transform(::nResult,'@E 9,999,999,999      '),'pts'} ),;
                     oBrw:gobottom(),;                   
                     oBrw:refresh(),;
                     ::cUltimaOp:='AP'             ,;  // AP = a Pesetas
                     oSay:SetText(transform(::nResult,'@E 9,999,999,999 pts')),;
                     nGet:=0                       ,;
                     cGet:=''                      ,;
                     oGet:SetText('')              ,;
                     oBtnIgual:Setfocus()          ,;
                     sysrefresh() ) UPDATE
             oBtnConv:cargo:='E'                 
   
    REDEFINE BUTTON oBtnConv2 ID 408 OF oDlg MESSAGE 'Convierte de PTS a Euro';
             ACTION ( iif(nGet<>0,::nResult:=round(nGet/166.386,2),::nResult:=round(::nResult/166.386,2)),;
                     aadd( ::aRolloCalc, {transform(::nResult,'@E 9,999,999,999.99 '),' €'} ),;
                     oBrw:gobottom(),;                   
                     oBrw:refresh(),;
                     ::cUltimaOp:='AE'             ,;  // AE = a Euros
                     oSay:SetText(transform(::nResult,'@E 9,999,999,999.99 €')),;
                     nGet:=0                       ,;
                     cGet:=''                      ,;
                     oGet:SetText('')              ,;
                     oBtnIgual:Setfocus()          ,;
                     sysrefresh() ) UPDATE
             oBtnConv:cargo:='P'    
             
    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()),NIL),;
                     iif(nGet<>0 .OR. at(".",cGet)>0,(;
                     cGet:=cGet+::cUltima       ,;
                     nGet:=val(cGet)),NIL)         ,;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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

/*  // TIENE QUE PONER TWBrowse en el .RC en vez de TXBrowse
    REDEFINE LISTBOX oBrw FIELDS ;
                     ::aRolloCalc[n][1],;
                     ::aRolloCalc[n][2];
             HEAD 'valor',' ';
             ID 212 OF oDlg FONT oFontLst COLOR  nrgb(0,0,0),nrgb(255,255,200) ;
             UPDATE
    
    oBrw:aJustify  :={.t.,.f.}
    oBrw:aColSizes :={GetFontInfo(oFontLst)[2] * 1.25 * 17, GetFontInfo(oFontLst)[2] * 1.25 * 3} //Empírico
    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:={|| iif(::aRolloCalc[n][2]=='=',nrgb(200,255,125),nrgb(255,255,200)) } 

    oDlg:={|nKey| ::TCalc_Teclas(nKey,oDlg)}
*/
    REDEFINE XBROWSE oBrw DATASOURCE ::aRolloCalc ;
             COLUMNS 1,2 ;
             HEADERS 'valor',' ';
             ID 212 OF oDlg FONT oFontLst COLOR  nrgb(0,0,0),nrgb(255,255,200) ;
             COLSIZES {GetFontInfo(oFontLst)[2] * 1.25 * 14, GetFontInfo(oFontLst)[2] * 1.25 * 3} ;//Empírico
             UPDATE
    
    WITH OBJECT oBrw
         :nRowDividerStyle:= LINESTYLE_NOLINES
         :nColDividerStyle:= LINESTYLE_NOLINES
         :nStretchCol:=STRETCHCOL_LAST
         :aJustify  :={.t.,2}
         //:= .F.
         //:= .T.
    end    
    oBrw:bClrStd := {|| {CLR_BLACK,iif(oBrw:aCols[2]:Value=='=',nrgb(200,255,125),nrgb(255,255,200)) } } 
    oDlg:bKeyDown:={|nKey| ::TCalc_Teclas(nKey,oDlg)}

   ACTIVATE DIALOG oDlg CENTERED ON INIT (if(lBorraAlInicio,oBtnBorra:CLICK(),.f.),oBrw:gobottom(),oBrw:refresh())
 
 //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) 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
return nil


Para el fichero de recursos "calculadora.RC" es el código siguiente:
Code (fw): Select all Collapse
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 7.00".

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US

CALCULADORA DIALOG DISCARDABLE 198, 20, 209, 176
STYLE WS_POPUP|WS_THICKFRAME|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
CAPTION "CALCULADORA"
{
  CONTROL "&1", 101, "Button", WS_TABSTOP, 114, 115, 14, 14
  CONTROL "&2", 102, "Button", WS_TABSTOP, 128, 115, 14, 14
  CONTROL "&4", 104, "Button", WS_TABSTOP, 114, 101, 14, 14
  CONTROL "&5", 105, "Button", WS_TABSTOP, 128, 101, 14, 14
  CONTROL "&6", 106, "Button", WS_TABSTOP, 142, 101, 14, 14
  CONTROL "&3", 103, "Button", WS_TABSTOP, 142, 115, 14, 14
  CONTROL "&7", 107, "Button", WS_TABSTOP, 114, 87, 14, 14
  CONTROL "&8", 108, "Button", WS_TABSTOP, 128, 87, 14, 14
  CONTROL "&9", 109, "Button", WS_TABSTOP, 142, 87, 14, 14
  CONTROL "&.", 110, "Button", WS_TABSTOP, 142, 129, 14, 14
  CONTROL "", 212, "TXBrowse", WS_TABSTOP|0x00a00000, 4, 6, 100, 163
  CONTROL "&-", 401, "Button", WS_TABSTOP, 161, 87, 14, 14
  CONTROL "&0", 100, "Button", WS_TABSTOP, 114, 129, 28, 14
  CONTROL "&*", 403, "Button", WS_TABSTOP, 161, 115, 14, 14
  CONTROL "&SALIR", 500, "Button", WS_TABSTOP, 167, 155, 39, 14
  CONTROL "&+", 402, "Button", WS_TABSTOP, 161, 101, 14, 14
  CONTROL "&/", 404, "Button", WS_TABSTOP, 161, 129, 14, 14
  CONTROL "&=", 405, "Button", WS_TABSTOP, 179, 129, 20, 14
  CONTROL "&RC", 425, "Button", WS_TABSTOP, 179, 87, 20, 14
  CONTROL "CE", 426, "Button", WS_TABSTOP, 179, 101, 20, 14
  CONTROL "+ / -", 111, "Button", WS_TABSTOP, 179, 115, 20, 14
  CONTROL "a &PTS", 407, "Button", WS_TABSTOP, 176, 14, 27, 14
  CONTROL "a &Euros", 408, "Button", WS_TABSTOP, 148, 14, 27, 14
  CONTROL "Text", 200, "Static", SS_RIGHT|WS_GROUP, 109, 49, 95, 13
  CONTROL "Text", 211, "Static", SS_RIGHT|WS_BORDER|WS_GROUP, 114, 71, 85, 13
  CONTROL "Resultado =", -1, "Static", SS_RIGHT|WS_GROUP, 164, 39, 40, 10
  CONTROL "", -1, "Static", SS_BLACKFRAME, 108, 67, 98, 80
  CONTROL "", -1, "Static", SS_BLACKFRAME, 108, 39, 98, 26
  CONTROL "Conversor", -1, "Button", BS_GROUPBOX, 144, 4, 62, 26
}
Posts: 563
Joined: Sun Oct 09, 2005 07:23 PM
Re: Calculadora Calculator
Posted: Tue Oct 27, 2020 03:16 PM
Buenas tardes,
Adjunto el código original de la clase para que la puedan seguir disfrutando:
Code (fw): Select all Collapse
/*
  TCALC.PRG   
  CLASE QUE PERMITE PONER UNA CALCULADORA CON ROLLO DE PAPEL VIRTUAL.
  Necesita el fichero de recursos: calculadora.RC

  Primera Versión: Junio del 2007 DC
  Ultima Revisión: 25/03/2015
  Adaptación a XBROWSE: 25/03/2015
  Autor: Verhoven.  ¡ Seguro les resultará de utilidad !
         1.- Queda autorizado su libre distribucion y uso, incluso con fines comerciales . 
         2.- El autor declina cualquier responsabilidad en caso de funcionamiento anómalo.

  Ejemplo: Hacemos una calculadora que se active pulsando F12:
           Para incluirla en un programa basta con poner después de la función main() del mismo.
           #include 'TCALC.PRG'
           public oCalc:=tCalc():new()
           setkey(VK_F12, {|| oCalc:calculadora(oWnd,'@E 9,999,999.9999 ')})
  
  Vea el significado de las variables de instancia y de las que se les pasan a los métodos para 
   aprovechar algunas posibilidades de configuración.
*/

#include "fivewin.ch"
#include "XBrowse.Ch"

CLASS TCalc
 DATA nResult             //Resultado de las operaciones en curso.    
 DATA aRolloCalc          //Operaciones realizadas desde la última vez que se borró todo.
 
 DATA cUltima, cUltimaop      
 DATA cPatronSalida       // cPatronSalida  -> Formato en que se pinta el resultado.    
    
 METHOD New() CONSTRUCTOR
 
 METHOD End()
     
 METHOD nCalculadigual(nGet)
     
 METHOD calculadora(oPadre,cPatronSalida,lBorraAlInicio)
                    // lBorraAlInicio -> Al llamar al método si está en .t. borra lo que hubiera.
                    //                    Si está en .f. ó NIL conserva las operaciones anteriores.
     
 METHOD TCalc_Teclas(nKey, oDlg)
ENDCLASS

//----------------------------------------------------------------------------//

METHOD New() CLASS TCalc
 ::aRolloCalc:={{'C',' '}}   
 ::nResult   :=0             
 
 ::cUltima   :=''
 ::cUltimaop :=''     
return SELF

//----------------------------------------------------------------------------//

METHOD End() CLASS TCalc
 ::aRolloCalc:={{'C',' '}}
 ::nResult   :=0

 ::cUltima   :=''
 ::cUltimaop :='' 
return NIL

//----------------------------------------------------------------------------//

METHOD calculadora(oPadre,cPatronSalida,lBorraAlInicio) CLASS TCalc
local oDlg
local oBtnSalir
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
local oBrw, n:=1
local oGet, nGet:=0 ,cGet:='', nGetAnt:=0
local oFont1
local oFontLst

if cPatronSalida=NIL .AND. ::cPatronSalida=NIL
   cPatronSalida:='@E 9,999,999,999.99 '  //Formato en que se pinta el resultado.
endif

//default cPatronSalida:='@E 9,999,999,999.99 '  //Formato en que se pinta el resultado.
default lBorraAlInicio :=.f.  // Al llamar al método si está en .t. borra lo que hubiera.
                              //  Si está en .f. entonces conserva las operaciones anteriores.

::cPatronSalida:=cPatronSalida

    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 TITLE 'CALCULADORA' FONT oFont

    REDEFINE BUTTON oBtnSalir ID 500 OF oDlg MESSAGE 'SALIR';
             ACTION oDlg:end() default CANCEL UPDATE
             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,NIL)),;
                     ::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,NIL)),;
                     ::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() ),NIL ),;
                     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 (::='CE'            ,;
                     iif(::cUltimaOp='=' .OR. ::cUltimaOp='AP' .OR. ::cUltimaOp='AE',(::cUltimaOp:='',::=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),NIL),;
                     iif(nGet<>0,(              ,;
                     cGet:=LEFT(cGet,len(cget)-1),;
                     nGet:=val(cGet)),NIL)       ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtnDel:=chr(8)
*/
    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()),NIL),;
                     iif(nGet<>0,(cGet:=LEFT(cGet,len(cget)-1),nGet:=val(cGet)),NIL),;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtnDel:cargo:=chr(8)
             
    REDEFINE BUTTON oBtnConv ID 407 OF oDlg MESSAGE 'Convierte de euros a PTS';
             ACTION ( iif(nGet<>0,::nResult:=round(nGet*166.386,0),::nResult:=round(::nResult*166.386,0)),;
                     aadd( ::aRolloCalc, {transform(::nResult,'@E 9,999,999,999      '),'pts'} ),;
                     oBrw:gobottom(),;                   
                     oBrw:refresh(),;
                     ::cUltimaOp:='AP'             ,;  // AP = a Pesetas
                     oSay:SetText(transform(::nResult,'@E 9,999,999,999 pts')),;
                     nGet:=0                       ,;
                     cGet:=''                      ,;
                     oGet:SetText('')              ,;
                     oBtnIgual:Setfocus()          ,;
                     sysrefresh() ) UPDATE
             oBtnConv:cargo:='E'                 
   
    REDEFINE BUTTON oBtnConv2 ID 408 OF oDlg MESSAGE 'Convierte de PTS a Euro';
             ACTION ( iif(nGet<>0,::nResult:=round(nGet/166.386,2),::nResult:=round(::nResult/166.386,2)),;
                     aadd( ::aRolloCalc, {transform(::nResult,'@E 9,999,999,999.99 '),' €'} ),;
                     oBrw:gobottom(),;                   
                     oBrw:refresh(),;
                     ::cUltimaOp:='AE'             ,;  // AE = a Euros
                     oSay:SetText(transform(::nResult,'@E 9,999,999,999.99 €')),;
                     nGet:=0                       ,;
                     cGet:=''                      ,;
                     oGet:SetText('')              ,;
                     oBtnIgual:Setfocus()          ,;
                     sysrefresh() ) UPDATE
             oBtnConv:cargo:='P'    
             
    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()),NIL),;
                     iif(nGet<>0 .OR. at(".",cGet)>0,(;
                     cGet:=cGet+::cUltima       ,;
                     nGet:=val(cGet)),NIL)         ,;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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()),NIL),;
                     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

/*  // TIENE QUE PONER TWBrowse en el .RC en vez de TXBrowse
    REDEFINE LISTBOX oBrw FIELDS ;
                     ::aRolloCalc[n][1],;
                     ::aRolloCalc[n][2];
             HEAD 'valor',' ';
             ID 212 OF oDlg FONT oFontLst COLOR  nrgb(0,0,0),nrgb(255,255,200) ;
             UPDATE
    
    oBrw:aJustify  :={.t.,.f.}
    oBrw:aColSizes :={GetFontInfo(oFontLst)[2] * 1.25 * 17, GetFontInfo(oFontLst)[2] * 1.25 * 3} //Empírico
    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:={|| iif(::aRolloCalc[n][2]=='=',nrgb(200,255,125),nrgb(255,255,200)) } 

    oDlg:={|nKey| ::TCalc_Teclas(nKey,oDlg)}
*/
    REDEFINE XBROWSE oBrw DATASOURCE ::aRolloCalc ;
             COLUMNS 1,2 ;
             HEADERS 'valor',' ';
             ID 212 OF oDlg FONT oFontLst COLOR  nrgb(0,0,0),nrgb(255,255,200) ;
             COLSIZES {GetFontInfo(oFontLst)[2] * 1.25 * 14, GetFontInfo(oFontLst)[2] * 1.25 * 3} ;//Empírico
             UPDATE
    
    WITH OBJECT oBrw
         :nRowDividerStyle:= LINESTYLE_NOLINES
         :nColDividerStyle:= LINESTYLE_NOLINES
         :nStretchCol:=STRETCHCOL_LAST
         :aJustify  :={.t.,2}
         //:= .F.
         //:= .T.
    end    
    oBrw:bClrStd := {|| {CLR_BLACK,iif(oBrw:aCols[2]:Value=='=',nrgb(200,255,125),nrgb(255,255,200)) } } 
    oDlg:bKeyDown:={|nKey| ::TCalc_Teclas(nKey,oDlg)}

   ACTIVATE DIALOG oDlg CENTERED ON INIT (if(lBorraAlInicio,oBtnBorra:CLICK(),.f.),oBrw:gobottom(),oBrw:refresh())
 
 //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) 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
return nil


Para el fichero de recursos "calculadora.RC" es el código siguiente:
Code (fw): Select all Collapse
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 7.00".

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US

CALCULADORA DIALOG DISCARDABLE 198, 20, 209, 176
STYLE WS_POPUP|WS_THICKFRAME|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
CAPTION "CALCULADORA"
{
  CONTROL "&1", 101, "Button", WS_TABSTOP, 114, 115, 14, 14
  CONTROL "&2", 102, "Button", WS_TABSTOP, 128, 115, 14, 14
  CONTROL "&4", 104, "Button", WS_TABSTOP, 114, 101, 14, 14
  CONTROL "&5", 105, "Button", WS_TABSTOP, 128, 101, 14, 14
  CONTROL "&6", 106, "Button", WS_TABSTOP, 142, 101, 14, 14
  CONTROL "&3", 103, "Button", WS_TABSTOP, 142, 115, 14, 14
  CONTROL "&7", 107, "Button", WS_TABSTOP, 114, 87, 14, 14
  CONTROL "&8", 108, "Button", WS_TABSTOP, 128, 87, 14, 14
  CONTROL "&9", 109, "Button", WS_TABSTOP, 142, 87, 14, 14
  CONTROL "&.", 110, "Button", WS_TABSTOP, 142, 129, 14, 14
  CONTROL "", 212, "TXBrowse", WS_TABSTOP|0x00a00000, 4, 6, 100, 163
  CONTROL "&-", 401, "Button", WS_TABSTOP, 161, 87, 14, 14
  CONTROL "&0", 100, "Button", WS_TABSTOP, 114, 129, 28, 14
  CONTROL "&*", 403, "Button", WS_TABSTOP, 161, 115, 14, 14
  CONTROL "&SALIR", 500, "Button", WS_TABSTOP, 167, 155, 39, 14
  CONTROL "&+", 402, "Button", WS_TABSTOP, 161, 101, 14, 14
  CONTROL "&/", 404, "Button", WS_TABSTOP, 161, 129, 14, 14
  CONTROL "&=", 405, "Button", WS_TABSTOP, 179, 129, 20, 14
  CONTROL "&RC", 425, "Button", WS_TABSTOP, 179, 87, 20, 14
  CONTROL "CE", 426, "Button", WS_TABSTOP, 179, 101, 20, 14
  CONTROL "+ / -", 111, "Button", WS_TABSTOP, 179, 115, 20, 14
  CONTROL "a &PTS", 407, "Button", WS_TABSTOP, 176, 14, 27, 14
  CONTROL "a &Euros", 408, "Button", WS_TABSTOP, 148, 14, 27, 14
  CONTROL "Text", 200, "Static", SS_RIGHT|WS_GROUP, 109, 49, 95, 13
  CONTROL "Text", 211, "Static", SS_RIGHT|WS_BORDER|WS_GROUP, 114, 71, 85, 13
  CONTROL "Resultado =", -1, "Static", SS_RIGHT|WS_GROUP, 164, 39, 40, 10
  CONTROL "", -1, "Static", SS_BLACKFRAME, 108, 67, 98, 80
  CONTROL "", -1, "Static", SS_BLACKFRAME, 108, 39, 98, 26
  CONTROL "Conversor", -1, "Button", BS_GROUPBOX, 144, 4, 62, 26
}