1; Defines
2!define buttonVisible "!insertMacro buttonVisible"
3!define buttonEnabled "!insertMacro buttonEnabled"
4!define buttonText "!insertMacro buttonText"
5
6; Interim macros
7!macro buttonVisible button value
8	Push ${button}
9	Push v
10	Push ${value}
11	Call Buttons
12!macroend
13
14!macro buttonEnabled button value
15	Push ${button}
16	Push e
17	Push ${value}
18	Call Buttons
19!macroend
20
21!macro buttonText button value
22	Push ${button}
23	Push t
24	Push "${value}"
25	Call Buttons
26!macroend
27
28
29; Function
30; Buttons FUnction
31;   Used to interact with the three default buttons; Back, Next, Cancel
32; Usage :
33;   Push Back|Next|Cancel
34;   Push v|e|t
35;   Push 1|0|<string>
36;   Call Buttons | Call Un.Buttons
37; Result :
38;   Interacts with the appropriate button
39;   If 'v', then 1 will set visible and 0 will set invisible
40;   If 'e', then 1 will set enabled and 0 will set disabled
41;   If 't', then <string> will be set as the button's new label text
42	Function Buttons
43									; Stack: <value> <mode> <button>
44		Exch $2 ; value				; Stack: $2 <mode> <button>
45		Exch						; Stack: <mode> $2 <button>
46		Exch $1 ; mode				; Stack: $1 $2 <button>
47		Exch 2						; Stack: <button> $2 $1
48		Exch $0 ; button			; Stack: $0 $2 $1
49		Push $3						; Stack: $3 $0 $2 $1
50
51		StrCmp $0 "Back" 0 +3
52			StrCpy $3 3
53			goto _setbutton
54		StrCmp $0 "Next" 0 +3
55			StrCpy $3 1
56			goto _setbutton
57		StrCmp $0 "Cancel" 0 _end
58			StrCpy $3 2
59
60		_setbutton:
61		GetDlgItem $3 $HWNDPARENT $3
62
63		StrCmp $1 "v" 0 +3
64			ShowWindow $3 $2
65			goto _end
66		StrCmp $1 "e" 0 +3
67			EnableWindow $3 $2
68			goto _end
69		StrCmp $1 "t" 0 _end
70			SendMessage $3 ${WM_SETTEXT} 0 "STR:$2"
71
72		_end:
73
74									; Stack: $3 $0 $2 $1
75		Pop $3						; Stack: $0 $2 $1
76		Pop $0						; Stack: $2 $1
77		Pop $2						; Stack: $1
78		Pop $1						; Stack: [clean]
79	FunctionEnd
80