Calculator revisited

Calculator revisited

Postby TimStone » Thu May 22, 2014 10:24 pm

A client recently updated from a DOS version of my software to the Windows version. ( waited 15 years to do so ).

He is obsessed with the fact that he had a calculator in GET fields in the DOS version ( some people just can't let go ). I don't have it in those fields under Windows because a lot of the fields trigger lookups or automatic processes.

However, I'm thinking maybe it would help to have one. Mine are old so they would need to be revised to look clean in Windows.

Does anyone have an implementation of a calculator for GET fields ? It might be a nice addition to the GET control ...

Thanks.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Calculator revisited

Postby José Luis Sánchez » Fri May 23, 2014 2:10 pm

Hello,
I use getcalc from Tim Sodtalbergs viewtopic.php?p=71631

Regards,
User avatar
José Luis Sánchez
 
Posts: 556
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España

Re: Calculator revisited

Postby Antonio Linares » Fri May 23, 2014 4:48 pm

Tim,

You can implement it quite easily using:

... GET ... ACTION WinExec( "calculator" )

If it is fine for you, then I help you to recover the value shown.

Of course it is even better to use a FWH calculator. Please try MsgCalc() from FWH
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Calculator revisited

Postby Antonio Linares » Fri May 23, 2014 4:53 pm

Or Timm's class which seems to work very fine:

viewtopic.php?p=159435#p159435

the solution that you prefer :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Calculator revisited

Postby TimStone » Fri May 23, 2014 5:06 pm

Hi Antonio,

Right now I'm using an inline GET calculator. I would love to see how to recover the value from the WIndows Calculator since it's traditional. I'm also going to play with MsgCalc( ) which might work out.

Thanks.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Calculator revisited

Postby Antonio Linares » Fri May 23, 2014 6:10 pm

Tim,

The problem with the Windows calculator is that unless the user press the "copy" menu option in the calculator, its value will not be saved.

If clicked, then we can retrieve its value from the clipboard. Its easy :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Calculator revisited

Postby TimStone » Fri May 23, 2014 6:49 pm

OK ... I took MsgCalc and re-did the layout a bit to be more conforming to my program ... so it's consistent with the existing fonts / brush etc. I will work OK ...

One quick question. I have a bitmap within a get ... no problem. However, would it be possible to put 2 bitmaps in there with 2 different action statements ?

Thanks
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Calculator revisited

Postby James Bott » Fri May 23, 2014 9:13 pm

Tim,

One quick question. I have a bitmap within a get ... no problem. However, would it be possible to put 2 bitmaps in there with 2 different action statements ?


Gee, give him the moon and he wants the stars.

Maybe you could just put a button next to the Get for the second action.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Calculator revisited

Postby TimStone » Fri May 23, 2014 9:18 pm

James,

We need to do lunch !

Oh ... I have the button next to the get already. It works fine, but I have a crotchety old client who likes to point out its "different"

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Calculator revisited

Postby James Bott » Fri May 23, 2014 9:45 pm

Tim,

We need to do lunch !


We do. Let me know when you are going to be in Carlsbad next time.

Oh ... I have the button next to the get already. It works fine, but I have a crotchety old client who likes to point out its "different"


My philosophy is to ignore them and they eventually give up. Or, offer to work on it for an (inflated) hourly fee--that usually changes their mind on how important it is. In this case you could just tell them that this is not a Windows standard design and thus you can't support it anymore.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Calculator revisited

Postby TimStone » Fri May 23, 2014 9:53 pm

This is a rather funny situation. The guy has been running the DOS system forever, and kept "not updating" to the Windows version until the XP issue arose. However, he paid all those (15) years for the updates ... so he has "sort of paid" for some special attention.

I'm in Carlsbad often.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Calculator revisited

Postby Verhoven » Wed May 28, 2014 11:52 am

May be usefull to you:

Code: Select all  Expand view
/*
  TCALC.PRG  
  CLASE QUE PERMITE PONER UNA CALCULADORA CON ROLLO DE PAPEL VIRTUAL.
  Necesita el fichero de recursos: TCALC.RC

  Primera Versión: Junio del 2007 DC
  Ultima Revisión: 23/09/2007
  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"

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,)),;
                     ::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 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()),),;
                     iif(nGet<>0 .or. at(".",cGet)>0,(              ,;
                     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',' ';
             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)}
   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
Verhoven
 
Posts: 520
Joined: Sun Oct 09, 2005 7:23 pm

Re: Calculator revisited

Postby karinha » Wed May 28, 2014 12:55 pm

Necesita el fichero de recursos: TCALC.RC

Regards,
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7805
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Calculator revisited

Postby Verhoven » Wed May 28, 2014 5:09 pm

Aquí lo copio:

Code: Select all  Expand view
Calculadora DIALOG 198, 20, 209, 176
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "CALCULADORA"
{
 PUSHBUTTON "&1", 101, 114, 115, 14, 14
 PUSHBUTTON "&2", 102, 128, 115, 14, 14
 PUSHBUTTON "&4", 104, 114, 101, 14, 14
 PUSHBUTTON "&5", 105, 128, 101, 14, 14
 PUSHBUTTON "&6", 106, 142, 101, 14, 14
 PUSHBUTTON "&3", 103, 142, 115, 14, 14
 PUSHBUTTON "&7", 107, 114, 87, 14, 14
 PUSHBUTTON "&8", 108, 128, 87, 14, 14
 PUSHBUTTON "&9", 109, 142, 87, 14, 14
 PUSHBUTTON "&.", 110, 142, 129, 14, 14
 CONTROL "", 212, "TWBrowse", 0 | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP, 4, 6, 100, 163
 PUSHBUTTON "&-", 401, 161, 87, 14, 14
 PUSHBUTTON "&0", 100, 114, 129, 28, 14
 PUSHBUTTON "&*", 403, 161, 115, 14, 14
 PUSHBUTTON "&SALIR", 500, 167, 155, 39, 14
 PUSHBUTTON "&+", 402, 161, 101, 14, 14
 PUSHBUTTON "&/", 404, 161, 129, 14, 14
 PUSHBUTTON "&=", 405, 179, 129, 20, 14
 PUSHBUTTON "&RC", 425, 179, 87, 20, 14
 PUSHBUTTON "CE", 426, 179, 101, 20, 14
 PUSHBUTTON "+ / -", 111, 179, 115, 20, 14
 PUSHBUTTON "a &PTS", 407, 176, 14, 27, 14
 PUSHBUTTON "a &Euros", 408, 148, 14, 27, 14
 RTEXT "Text", 200, 109, 49, 95, 13
 RTEXT "Text", 211, 114, 71, 85, 13, SS_RIGHT | WS_BORDER | WS_GROUP
 RTEXT "Resultado =", -1, 164, 39, 40, 10
 CONTROL "", -1, "static", SS_BLACKFRAME | WS_CHILD | WS_VISIBLE, 108, 67, 98, 80
 CONTROL "", -1, "static", SS_BLACKFRAME | WS_CHILD | WS_VISIBLE, 108, 39, 98, 26
 GROUPBOX "Conversor", -1, 144, 4, 62, 26, BS_GROUPBOX
}
 
Verhoven
 
Posts: 520
Joined: Sun Oct 09, 2005 7:23 pm

Re: Calculator revisited

Postby Verhoven » Wed May 28, 2014 5:11 pm

Está escrito con el WorkShop.
It was written with WorkShop.
Verhoven
 
Posts: 520
Joined: Sun Oct 09, 2005 7:23 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 61 guests