Relabel mscheckbox caption
Moderators: Dorian (MJT support), JRL
Relabel mscheckbox caption
I am not very proficient with dialog boxes so please be gentle I script mainly for background processes. I have a dialog box with a checkbox that the caption is defined by a variable. When that variable changes and the script returns to the dialog box, the original caption is still showing. How can I update the caption. Sorry if I have missed this somewhere, I have searched and cannot find anything.
I could be wrong but it doesn't look like there is a good way to dynamically change the name of a checkbox. You might be able to use SetControlText> or if you have version 11 you might be able to set up a stack of checkboxes all located in the same spot and turn one of them on at a time using SerDialogObjectVisible>.
That said. what I would suggest is to remove the checkbox name and substitute a label. Labels are easy to change dynamically.
Heres a short demo script to illustrate. Be sure to make the last number value in the checkbox definition "12" so that the checkbox shows but the label doesn't get covered by the checkbox text space.
[code]
Let>PredefinedLabel=Test One
Dialog>Dialog1
Caption=Test
Width=239
Height=139
Top=0
Left=CENTER
Label=%PredefinedLabel%,91,23,true
CheckBox=msCheckBox1,,75,23,12,True
Button=Test 1,16,60,75,25,3
Button=Test 2,126,59,75,25,4
EndDialog>Dialog1
Show>dialog1
Label>Loop
GetDialogAction>dialog1,res1
If>res1=2
Exit>0
EndIF
If>res1=3
Let>dialog1.mslabel1=Test One
EndIF
If>res1=4
Let>dialog1.mslabel1=Test Two
EndIF
Wait>0.01
Goto>Loop
[/code]
That said. what I would suggest is to remove the checkbox name and substitute a label. Labels are easy to change dynamically.
Heres a short demo script to illustrate. Be sure to make the last number value in the checkbox definition "12" so that the checkbox shows but the label doesn't get covered by the checkbox text space.
[code]
Let>PredefinedLabel=Test One
Dialog>Dialog1
Caption=Test
Width=239
Height=139
Top=0
Left=CENTER
Label=%PredefinedLabel%,91,23,true
CheckBox=msCheckBox1,,75,23,12,True
Button=Test 1,16,60,75,25,3
Button=Test 2,126,59,75,25,4
EndDialog>Dialog1
Show>dialog1
Label>Loop
GetDialogAction>dialog1,res1
If>res1=2
Exit>0
EndIF
If>res1=3
Let>dialog1.mslabel1=Test One
EndIF
If>res1=4
Let>dialog1.mslabel1=Test Two
EndIF
Wait>0.01
Goto>Loop
[/code]
Yes, that is the way I have it working now, but to make the dialog a little more user-friendly I made the checkbox 300 wide with no text. I then placed the label over it. The wide checkbox makes it easier to check. This works great on XP, but on an older OS (W2K) the label is not is not visible. So now I have the width of the checkbox caption as 2 with the label beside it. Works, but would be smoother not to mention smaller because this dialog has 100 checkboxes. The other alternative is to write a batch file to temp directory that waits 3 seconds and restarts the compiled script.