Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Currency to add sum of 2 numbers
#12
I took TheVig's example and tweaked it a little.

Function Ghost_Dialog
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 170 109 "Dialog"
;1 Button 0x54030001 0x4 38 88 48 14 "OK"
;2 Button 0x54030000 0x4 94 88 48 14 "Cancel"
;3 Edit 0x54030080 0x200 22 20 42 14 ""
;4 Edit 0x54030080 0x200 98 20 42 14 ""
;5 Edit 0x54030080 0x200 60 66 44 14 ""
;6 Button 0x54032000 0x0 58 38 48 14 "Get Total"
;7 Static 0x54000000 0x0 30 10 24 8 "Price 1"
;8 Static 0x54000000 0x0 106 10 24 8 "Price 2"
;9 Static 0x54000000 0x0 72 58 18 8 "Total"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

str controls = "3 4 5"
str e3 e4 e5
e3="$0.00"
e4="$0.00"
e5="$0.00"
if(!ShowDialog("Ghost_Dialog" &Ghost_Dialog &controls)) ret

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam

;Grabs money Value of Price 1.
,case EN_KILLFOCUS<<16|3
,CURRENCY- c1
,str wText1.getwintext(id(3 hDlg))
,wText1.trim('$')
,wText1.findreplace("," "")
,c1=val(wText1 2)
,wText1.getwintext(id(3 hDlg))
,wText1.trim('$')
,wText1.format("$%s" wText1)
,wText1.setwintext(id(3 hDlg))

;Grabs money value of Price 2.
,case EN_KILLFOCUS<<16|4
,CURRENCY- c2
,str wText2.getwintext(id(4 hDlg))
,wText2.trim('$')
,wText2.findreplace("," "")
,c2=val(wText2 2)
,wText2.getwintext(id(4 hDlg))
,wText2.trim('$')
,wText2.format("$%s" wText2)
,wText2.setwintext(id(4 hDlg))

,case 6 ;;Hit button for Combined total.
,CURRENCY c3
,c3.add(c1 c2)
,str Total=c3
,Total.format("$%s" Total)
,Total.setwintext(id(5 hDlg))
,case IDOK
,case IDCANCEL
ret 1
Taking on Quick Macros one day at a time


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)