April 18, 2024, 01:41:01 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


A class to control windows calculator

Started by sapero, November 12, 2008, 09:21:09 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sapero

I found today a request on other forum for this tool. This is a class that makes possible to control remptelly running calc.exe with simple methods.

Main methods:
Start launchest the calculator.
ClickButton - self explaining
InvokeMenu - click menu item
GetResult - returns the text from calc's edit box.

Parameter for ClickButton and InvokeMenu can be a string, or a word in range 0-65535 - same rule as the one from winapi resource functions. This is usefull when you want your program to be OS-language independent.
CWinCalc calc
string result

if (calc.Start())
' setup view mode
'calc.InvokeMenu(305) ' standard
calc.InvokeMenu(304) ' scientific

' calculate "5*6"
calc.ClickButton("5")
calc.ClickButton("*")
calc.ClickButton("6")
calc.ClickButton("=")

calc.GetResult(result, 256)
print "5*6=", result

calc.Close()
endif


The attached archive contain source code and static library.