Tabs within a Dialog Box
Keywords: tab order numcontrols
Question:
I've create a Dialog box in my WinBatch program. I want to allow only specific data (i.e. a 2 digit number) to be entered into 5 different fields.As a user provides input I check the fields for errors. If a field does not match my requirements (a valid 2 digit number), I recall the dialog box again until all info is correct.
On the first round of input, all fields are entered. Then it performs an error checking routine. If the first field is correct then it goes to field 2, etc, etc.
My problem: I want it to automatically tab down to the field in error when the dialog box is called up again. So far I have not figured out a way to do it. Any help would be appreciated.
Answer:
Ack. The tab order of the dialog box is defined by the 01 02 03 etc. on the end of the control IDs.Although not particularly recommended, I can think of any particular reason the following scheme should not work except that its a lot of work and there is a good chance it will get messed up somehow.
Let's say you arranged your dialog box so that dialog01 thru dialog05 are the input fields. Now you decide dialog 03 is bad.
Right after the place where all the dialogxx's are defined, but before the dialog statement, you could rotate the numbers so that the dialog03 becomes dialog01.
Note it's not good just to swap 01 and 03 as that would mess up the natural tab ordering, but rotating them as below should work.
numcontrols=5 ; STARTING at 01 setactivecontrol=3 ; SET 3 TO be first for xx = 1 to numcontrols currentctl=((setactivecontrol+xx-2) mod numcontrols)+1 ; its magic... targid=strfixleft(xx,"0",2) srcid=strfixleft(currentctl,"0",2) if xx==1 then saveit=DIALOG%targid% DIALOG%targid% = DIALOG%srcid% if xx==numcontrols then DIALOG%srcid%=saveit nextthen your Dialog("DIALOG") statement goes here.It might be buggy but the idea ought to work.
Article ID: W12830Filename: Changing Tab Order in Dialog.txt