Silverfrost Forums

Welcome to our forums

Autotabbing between fields, for example DD MM YY

24 Jun 2011 4:19 #8461

I am wanting to auto-tab between fields when a field gets filled.

For example entering Date of Birth when each of the DD MM YY fields has 2 characters the user should expect to immediately key them in without having to Tab between them.

I realise that a callback can be done and therefore a check performed on the number of characters keyed in. But, how does one inform Clearwin+/Windows to effectively 'auto-tab to the next field' ?

28 Jun 2011 12:03 (Edited: 29 Jun 2011 8:07) #8478

I have puzzled over this in the past - but gave up. The problem is that 'auto-tabbing' is a bit unconventional in Windows.

As far as I got (before I gave up) was to find on MSDN that there was a SetFocus function so that you could set the focus to any control for which you had the handle (MSDN talks about windows, but a control is also a window in MSDN language!). You could call this in the callback after you checked that the 2 characters were admissable, and get the [color=red:42a0ce1288]handle[/color:42a0ce1288] for every control with %lc.

However (and this is what really stopped me in my tracks) was the note that said not to use the function, but instead, CALL SendMessage so that internal bookkeeping was updated.

Perhaps you will get further than I did by Googling 'SetFocus' and 'MSDN' together!

Eddie

EDIT: When I said 'get the focus', I meant 'get the handle' - sorry. Corrected above in red.

28 Jun 2011 4:15 #8479

I would use %lc and SetFocus which you should find listed in win32api.ins.

3 Jul 2011 9:49 #8503

Many thanks, your suggestions work fine.

4 Jul 2011 7:29 #8508

Steve,

Did you manage it with %lc and SetFocus, as I first thought and Paul advised? Did you get the reputed side effects, and was it necessary therefore to resort to SendMessage? If so, how did the side effects (if any) manifest in an FTN95 program!

Eddie

24 Jul 2011 4:07 #8616

Eddie,

Sorry did not get back to you earlier. Setting up %lc for the MM and YY fields and then having a callback on the DD and MM which SetFocus to the next field when 2 characters were identified. Very straight forward and worked first time and with no 'side effects' ( latter not understood ).

Thanks for your input.

24 Jul 2011 5:21 #8617

Steve,

I didn't understand 'side effects' either. MSDN says this:

When handling other dialog messages if you use SetFocus (and not WM_NEXTDLGCTL) it prevents the dialog manager from updating its internal bookkeeping. For example, it might cause the dialog manager to display the wrong default pushbutton or fail to select the text of an edit control. For details see Raymond Chen's book The Old New Thing, page 227, 'How to set focus in a dialog box.' (Or see his blog.)

Whatever that means! (It was enough to put me off ....)

You can get to the 'official' MSDN explanation by Googling SetFocus and MSDN together. (And try Googling [color=red:68f631026c]Raymond Chen blog SetFocus[/color:68f631026c]!)

Eddie

Please login to reply.