IonicWind Software

IWBasic => Object Oriented Programming => Topic started by: sapero on November 12, 2008, 09:21:09 AM

Title: A class to control windows calculator
Post by: sapero on November 12, 2008, 09:21:09 AM
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.