View previous topic :: View next topic |
Author |
Message |
Steve
Joined: 23 Feb 2007 Posts: 73
|
Posted: Fri Jun 24, 2011 5:19 pm Post subject: Autotabbing between fields, for example DD MM YY |
|
|
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" ? |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Tue Jun 28, 2011 1:03 pm Post subject: |
|
|
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 handle 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.
Last edited by LitusSaxonicum on Wed Jun 29, 2011 9:07 am; edited 1 time in total |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Tue Jun 28, 2011 5:15 pm Post subject: |
|
|
I would use %lc and SetFocus which you should find listed in win32api.ins. |
|
Back to top |
|
 |
Steve
Joined: 23 Feb 2007 Posts: 73
|
Posted: Sun Jul 03, 2011 10:49 pm Post subject: |
|
|
Many thanks, your suggestions work fine. |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Mon Jul 04, 2011 8:29 pm Post subject: |
|
|
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 |
|
Back to top |
|
 |
Steve
Joined: 23 Feb 2007 Posts: 73
|
Posted: Sun Jul 24, 2011 5:07 pm Post subject: |
|
|
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. |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Sun Jul 24, 2011 6:21 pm Post subject: |
|
|
Steve,
I didn't understand "side effects" either. MSDN says this:
Quote: | 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 Raymond Chen blog SetFocus!)
Eddie |
|
Back to top |
|
 |
|