Riporto questa discussione apparsa nella M.L. ufficiale:
" I have a form with a textbox that "MUST" be filled in before moving on
to the next control or any other control within the form. Fine, so I
implement a txtManditory_LostFocus method that just checks that there is
some text in there.
My problems are:
1) if the entire form loses focus, the lostfocus event fires.
2) if the user tries to click on the form menu the lost focus event fires.
I think I have got around 1) by using Object.Lock in a Form_Leave()
handler, but 2) has got me stumped.
Any clues?
tia
Bruce "
" Salut Bruce,
disable all others and set a 'continue' (enabled) behind .....
or let the user only enter to the form after filling that field in a
single form/field
--
Amicalement
Charlie "
" This is how to do with svn version ...
Public Sub Form_Open()
Balloon.Delay = 1000
End
Public Sub TextBox1_LostFocus()
If IsNull(Application.ActiveControl) Then Return
If Len(Last.Text) < 8 Then
Balloon.Error("this must be filled before anything else", Last)
TextBox1.Select()
Last.SetFocus
Endif
End
I don't know if Application.ActiveControl is in the last 3.5
packages, but it is what you need.
http://gambasdoc.org/help/comp/gb.qt4/application/activecontrol?v3
Returns the control having the focus.
But return null for a menu or when the form lose the focus
--
Fabien Bodard "
...continua...
" Or
If Application.ActiveControl.Window <> Me.Window
Fabien Bodard "
" Ah! I was so close. In fact probably too close to see the obvious.
Thanks Fabien for taking the time.
Bruce "