Cannot call set focus from valid ... 
Author Message
 Cannot call set focus from valid ...

Hi,

Weird problem !
I have a MainForm (modelles!) where the user can open other SubForms (also
modeless).
So the user can open as many SubForms he wants.
If he want to do this then I have a weird problem.
(I will try to explain...)
If he opens (from the MainForm) a SubForm,
after openening a SubForm the user can click on an object or the focus will
autom. be set
on an object WITH a Valid event on that SubForm,
if the focus is set and the user clicks or set the focus back to the
MainForm
I get an error Cannot Call Set Focus From Valid,...

The weird thing is I only get this error when there is a Wait Window " "
in the Valid Event. If I don't display that Wait Window I don't have that
problem.
Of course you could say to delete those messages but
I really need them because they tell that there is something wrong with the
entered value.

Anybody an idea on how to solve this ?

thanks in advance

christophe
belgium



Sun, 04 Sep 2005 16:33:22 GMT  
 Cannot call set focus from valid ...
You can not use SetFocus inside a valid event. Somehow you are, either in
this, or a superclass.

Andrew R.


Quote:
> Hi,

> Weird problem !
> I have a MainForm (modelles!) where the user can open other SubForms (also
> modeless).
> So the user can open as many SubForms he wants.
> If he want to do this then I have a weird problem.
> (I will try to explain...)
> If he opens (from the MainForm) a SubForm,
> after openening a SubForm the user can click on an object or the focus
will
> autom. be set
> on an object WITH a Valid event on that SubForm,
> if the focus is set and the user clicks or set the focus back to the
> MainForm
> I get an error Cannot Call Set Focus From Valid,...

> The weird thing is I only get this error when there is a Wait Window " "
> in the Valid Event. If I don't display that Wait Window I don't have that
> problem.
> Of course you could say to delete those messages but
> I really need them because they tell that there is something wrong with
the
> entered value.

> Anybody an idea on how to solve this ?

> thanks in advance

> christophe
> belgium



Sun, 04 Sep 2005 18:57:19 GMT  
 Cannot call set focus from valid ...
Andrew,

That's just the weird thing
I don't have a Setfocus in the valid event.
I can prove this because when I don't display
a Wait Window and leave all the rest as it is,
then I don't get that message.

christophe
Belgium



Quote:
> You can not use SetFocus inside a valid event. Somehow you are, either in
> this, or a superclass.

> Andrew R.



> > Hi,

> > Weird problem !
> > I have a MainForm (modelles!) where the user can open other SubForms
(also
> > modeless).
> > So the user can open as many SubForms he wants.
> > If he want to do this then I have a weird problem.
> > (I will try to explain...)
> > If he opens (from the MainForm) a SubForm,
> > after openening a SubForm the user can click on an object or the focus
> will
> > autom. be set
> > on an object WITH a Valid event on that SubForm,
> > if the focus is set and the user clicks or set the focus back to the
> > MainForm
> > I get an error Cannot Call Set Focus From Valid,...

> > The weird thing is I only get this error when there is a Wait Window " "
> > in the Valid Event. If I don't display that Wait Window I don't have
that
> > problem.
> > Of course you could say to delete those messages but
> > I really need them because they tell that there is something wrong with
> the
> > entered value.

> > Anybody an idea on how to solve this ?

> > thanks in advance

> > christophe
> > belgium



Sun, 04 Sep 2005 20:08:21 GMT  
 Cannot call set focus from valid ...
christophe,
Are you saying that when you add something like:
WAIT WINDOW "Valid Event"
in the Valid() method you don't get the error?
If yes, have you tried?:
DODEFAULT()
WAIT WINDOW "Valid Event"

If this "fails", then I must assume your control is based on a class that has other code - including
a SETFOCUS() - in the inherited VALID() method code.

Rick


Quote:
> Andrew,

> That's just the weird thing
> I don't have a Setfocus in the valid event.
> I can prove this because when I don't display
> a Wait Window and leave all the rest as it is,
> then I don't get that message.

> christophe
> Belgium



> > You can not use SetFocus inside a valid event. Somehow you are, either in
> > this, or a superclass.

> > Andrew R.



> > > Hi,

> > > Weird problem !
> > > I have a MainForm (modelles!) where the user can open other SubForms
> (also
> > > modeless).
> > > So the user can open as many SubForms he wants.
> > > If he want to do this then I have a weird problem.
> > > (I will try to explain...)
> > > If he opens (from the MainForm) a SubForm,
> > > after openening a SubForm the user can click on an object or the focus
> > will
> > > autom. be set
> > > on an object WITH a Valid event on that SubForm,
> > > if the focus is set and the user clicks or set the focus back to the
> > > MainForm
> > > I get an error Cannot Call Set Focus From Valid,...

> > > The weird thing is I only get this error when there is a Wait Window " "
> > > in the Valid Event. If I don't display that Wait Window I don't have
> that
> > > problem.
> > > Of course you could say to delete those messages but
> > > I really need them because they tell that there is something wrong with
> > the
> > > entered value.

> > > Anybody an idea on how to solve this ?

> > > thanks in advance

> > > christophe
> > > belgium



Sun, 04 Sep 2005 22:18:36 GMT  
 Cannot call set focus from valid ...
Rick,

Yes, But it's more the other way,
When I Add WAIT WINDOW "Valid Event"
then I get an error when the user hit the other "MainForm"
And DoDefault() doesn't help !
And no I think it's not hearitted, well
at least I think I've made and added those forms and textboxes with
the formdesigner so I don't think the base class have a SetFocus.

But I forgot to tell that the error message mention
the MainForm.Activate event as the program with an error.
There I place a SetFocus but there it should be harmless.

I played around a little bit more
and the weirdness goes on
if I add Wait Window NOWAIT "valid event"
the error goes away (but then the user can't read the message) !

It also goes away when the MainForm itself set his focus.
(hope this is clear...).  I have a CommandButton on the MainForm
when the user moves over it with the mouse the focus is set on a
MainForm.Textbox.  Also Then I don't get any error messages with or
without NOWAIT  !

Christophe
Belgium



Quote:
> christophe,
> Are you saying that when you add something like:
> WAIT WINDOW "Valid Event"
> in the Valid() method you don't get the error?
> If yes, have you tried?:
> DODEFAULT()
> WAIT WINDOW "Valid Event"

> If this "fails", then I must assume your control is based on a class that

has other code - including
Quote:
> a SETFOCUS() - in the inherited VALID() method code.

> Rick



> > Andrew,

> > That's just the weird thing
> > I don't have a Setfocus in the valid event.
> > I can prove this because when I don't display
> > a Wait Window and leave all the rest as it is,
> > then I don't get that message.

> > christophe
> > Belgium



> > > You can not use SetFocus inside a valid event. Somehow you are, either
in
> > > this, or a superclass.

> > > Andrew R.



> > > > Hi,

> > > > Weird problem !
> > > > I have a MainForm (modelles!) where the user can open other SubForms
> > (also
> > > > modeless).
> > > > So the user can open as many SubForms he wants.
> > > > If he want to do this then I have a weird problem.
> > > > (I will try to explain...)
> > > > If he opens (from the MainForm) a SubForm,
> > > > after openening a SubForm the user can click on an object or the
focus
> > > will
> > > > autom. be set
> > > > on an object WITH a Valid event on that SubForm,
> > > > if the focus is set and the user clicks or set the focus back to the
> > > > MainForm
> > > > I get an error Cannot Call Set Focus From Valid,...

> > > > The weird thing is I only get this error when there is a Wait Window
" "
> > > > in the Valid Event. If I don't display that Wait Window I don't have
> > that
> > > > problem.
> > > > Of course you could say to delete those messages but
> > > > I really need them because they tell that there is something wrong
with
> > > the
> > > > entered value.

> > > > Anybody an idea on how to solve this ?

> > > > thanks in advance

> > > > christophe
> > > > belgium



Sun, 04 Sep 2005 23:46:27 GMT  
 Cannot call set focus from valid ...
I have found that you cannot place a set focus in a valid event.  You can
move the set focus to the lost focus event.  This makes sense since the
valid method is actually validating data that the user enters into the
field.  Instead of using Wait Window try using Messagebox to send messages
to the user.
John.


Quote:
> Rick,

> Yes, But it's more the other way,
> When I Add WAIT WINDOW "Valid Event"
> then I get an error when the user hit the other "MainForm"
> And DoDefault() doesn't help !
> And no I think it's not hearitted, well
> at least I think I've made and added those forms and textboxes with
> the formdesigner so I don't think the base class have a SetFocus.

> But I forgot to tell that the error message mention
> the MainForm.Activate event as the program with an error.
> There I place a SetFocus but there it should be harmless.

> I played around a little bit more
> and the weirdness goes on
> if I add Wait Window NOWAIT "valid event"
> the error goes away (but then the user can't read the message) !

> It also goes away when the MainForm itself set his focus.
> (hope this is clear...).  I have a CommandButton on the MainForm
> when the user moves over it with the mouse the focus is set on a
> MainForm.Textbox.  Also Then I don't get any error messages with or
> without NOWAIT  !

> Christophe
> Belgium



> > christophe,
> > Are you saying that when you add something like:
> > WAIT WINDOW "Valid Event"
> > in the Valid() method you don't get the error?
> > If yes, have you tried?:
> > DODEFAULT()
> > WAIT WINDOW "Valid Event"

> > If this "fails", then I must assume your control is based on a class
that
> has other code - including
> > a SETFOCUS() - in the inherited VALID() method code.

> > Rick



> > > Andrew,

> > > That's just the weird thing
> > > I don't have a Setfocus in the valid event.
> > > I can prove this because when I don't display
> > > a Wait Window and leave all the rest as it is,
> > > then I don't get that message.

> > > christophe
> > > Belgium



> > > > You can not use SetFocus inside a valid event. Somehow you are,
either
> in
> > > > this, or a superclass.

> > > > Andrew R.



> > > > > Hi,

> > > > > Weird problem !
> > > > > I have a MainForm (modelles!) where the user can open other
SubForms
> > > (also
> > > > > modeless).
> > > > > So the user can open as many SubForms he wants.
> > > > > If he want to do this then I have a weird problem.
> > > > > (I will try to explain...)
> > > > > If he opens (from the MainForm) a SubForm,
> > > > > after openening a SubForm the user can click on an object or the
> focus
> > > > will
> > > > > autom. be set
> > > > > on an object WITH a Valid event on that SubForm,
> > > > > if the focus is set and the user clicks or set the focus back to
the
> > > > > MainForm
> > > > > I get an error Cannot Call Set Focus From Valid,...

> > > > > The weird thing is I only get this error when there is a Wait
Window
> " "
> > > > > in the Valid Event. If I don't display that Wait Window I don't
have
> > > that
> > > > > problem.
> > > > > Of course you could say to delete those messages but
> > > > > I really need them because they tell that there is something wrong
> with
> > > > the
> > > > > entered value.

> > > > > Anybody an idea on how to solve this ?

> > > > > thanks in advance

> > > > > christophe
> > > > > belgium



Mon, 05 Sep 2005 02:16:42 GMT  
 Cannot call set focus from valid ...
Hi, christophe!
You wrote  on Wed, 19 Mar 2003 16:46:27 +0100:

I assume that if you have WAIT WINDOW in Valid event, then you want to
notify user about some problem in the data (s)he entered there, so this
Valid method should prevent him/her from leaving this control... Am I right?
If so, you may try to use MESSAGEBOX() function for such a notifications. I
suppose that WAIT WINDOW (as it is VFP managed window) is less "modal" then
MESSAGEBOX one, so you can click other controls when it is active, but
MESSAGEBOX will prevent you from clicking on anything but this dialog
window. As it should be IMHO...

WBR, Igor



Mon, 05 Sep 2005 04:22:29 GMT  
 Cannot call set focus from valid ...
Igor,

Absolutaly right,
The MessageBox() did his job very well.
But I don't really like it.
"My users" are used to see those Wait Window messages
and I have tons of it with small messages like "Please enter a value"
or just "Wait ..." or "Printing ..." or "Sorry, not available."
I only used a MessageBox() when it was more severe
like "You really want to delete this ?".

I also found, and this is in favour of a messagebox :-(
that a Wait Window can't be used in a As top level Modeless form.
Well at least it is shown but it pops up the _Screen window !
Maybe I will have to rethink the communication with my users.
Mayby I could let it talk, this would be cool ...

thanks a lot for the time spend.

Christophe
Belgium



Quote:
> Hi, christophe!
> You wrote  on Wed, 19 Mar 2003 16:46:27 +0100:

> I assume that if you have WAIT WINDOW in Valid event, then you want to
> notify user about some problem in the data (s)he entered there, so this
> Valid method should prevent him/her from leaving this control... Am I
right?
> If so, you may try to use MESSAGEBOX() function for such a notifications.
I
> suppose that WAIT WINDOW (as it is VFP managed window) is less "modal"
then
> MESSAGEBOX one, so you can click other controls when it is active, but
> MESSAGEBOX will prevent you from clicking on anything but this dialog
> window. As it should be IMHO...

> WBR, Igor



Mon, 05 Sep 2005 16:08:01 GMT  
 Cannot call set focus from valid ...
John,

the messagebox does a good job thanks
and no I don't have a SetFocus in the Valid.
It's the Wait Window that goes besurk

thanks

christophe
belgium


Quote:
> I have found that you cannot place a set focus in a valid event.  You can
> move the set focus to the lost focus event.  This makes sense since the
> valid method is actually validating data that the user enters into the
> field.  Instead of using Wait Window try using Messagebox to send messages
> to the user.
> John.



> > Rick,

> > Yes, But it's more the other way,
> > When I Add WAIT WINDOW "Valid Event"
> > then I get an error when the user hit the other "MainForm"
> > And DoDefault() doesn't help !
> > And no I think it's not hearitted, well
> > at least I think I've made and added those forms and textboxes with
> > the formdesigner so I don't think the base class have a SetFocus.

> > But I forgot to tell that the error message mention
> > the MainForm.Activate event as the program with an error.
> > There I place a SetFocus but there it should be harmless.

> > I played around a little bit more
> > and the weirdness goes on
> > if I add Wait Window NOWAIT "valid event"
> > the error goes away (but then the user can't read the message) !

> > It also goes away when the MainForm itself set his focus.
> > (hope this is clear...).  I have a CommandButton on the MainForm
> > when the user moves over it with the mouse the focus is set on a
> > MainForm.Textbox.  Also Then I don't get any error messages with or
> > without NOWAIT  !

> > Christophe
> > Belgium



> > > christophe,
> > > Are you saying that when you add something like:
> > > WAIT WINDOW "Valid Event"
> > > in the Valid() method you don't get the error?
> > > If yes, have you tried?:
> > > DODEFAULT()
> > > WAIT WINDOW "Valid Event"

> > > If this "fails", then I must assume your control is based on a class
> that
> > has other code - including
> > > a SETFOCUS() - in the inherited VALID() method code.

> > > Rick



> > > > Andrew,

> > > > That's just the weird thing
> > > > I don't have a Setfocus in the valid event.
> > > > I can prove this because when I don't display
> > > > a Wait Window and leave all the rest as it is,
> > > > then I don't get that message.

> > > > christophe
> > > > Belgium



> > > > > You can not use SetFocus inside a valid event. Somehow you are,
> either
> > in
> > > > > this, or a superclass.

> > > > > Andrew R.



> > > > > > Hi,

> > > > > > Weird problem !
> > > > > > I have a MainForm (modelles!) where the user can open other
> SubForms
> > > > (also
> > > > > > modeless).
> > > > > > So the user can open as many SubForms he wants.
> > > > > > If he want to do this then I have a weird problem.
> > > > > > (I will try to explain...)
> > > > > > If he opens (from the MainForm) a SubForm,
> > > > > > after openening a SubForm the user can click on an object or the
> > focus
> > > > > will
> > > > > > autom. be set
> > > > > > on an object WITH a Valid event on that SubForm,
> > > > > > if the focus is set and the user clicks or set the focus back to
> the
> > > > > > MainForm
> > > > > > I get an error Cannot Call Set Focus From Valid,...

> > > > > > The weird thing is I only get this error when there is a Wait
> Window
> > " "
> > > > > > in the Valid Event. If I don't display that Wait Window I don't
> have
> > > > that
> > > > > > problem.
> > > > > > Of course you could say to delete those messages but
> > > > > > I really need them because they tell that there is something
wrong
> > with
> > > > > the
> > > > > > entered value.

> > > > > > Anybody an idea on how to solve this ?

> > > > > > thanks in advance

> > > > > > christophe
> > > > > > belgium



Mon, 05 Sep 2005 15:38:58 GMT  
 Cannot call set focus from valid ...


Quote:

> I also found, and this is in favour of a messagebox :-(
> that a Wait Window can't be used in a As top level Modeless form.
> Well at least it is shown but it pops up the _Screen window !
> Maybe I will have to rethink the communication with my users.
> Mayby I could let it talk, this would be cool ...

Yes quite strange really. In VFP 5 it shows, in later versions it does not.

Andrew R.



Mon, 05 Sep 2005 19:07:20 GMT  
 Cannot call set focus from valid ...
Hi,
If you really want to rethink the way you handle messages in your
application, I suggest reading the section "How can I simplify getting
messages to my users?" in the book, "1001 Things You Wanted to Know About
Visual FoxPro" by Hentzenwerke Publishing.  This article shows you how to
easily develop a table (.dbf) of messages and access those messages with one
call.  Very nice.
John.


Quote:
> Igor,

> Absolutaly right,
> The MessageBox() did his job very well.
> But I don't really like it.
> "My users" are used to see those Wait Window messages
> and I have tons of it with small messages like "Please enter a value"
> or just "Wait ..." or "Printing ..." or "Sorry, not available."
> I only used a MessageBox() when it was more severe
> like "You really want to delete this ?".

> I also found, and this is in favour of a messagebox :-(
> that a Wait Window can't be used in a As top level Modeless form.
> Well at least it is shown but it pops up the _Screen window !
> Maybe I will have to rethink the communication with my users.
> Mayby I could let it talk, this would be cool ...

> thanks a lot for the time spend.

> Christophe
> Belgium



> > Hi, christophe!
> > You wrote  on Wed, 19 Mar 2003 16:46:27 +0100:

> > I assume that if you have WAIT WINDOW in Valid event, then you want to
> > notify user about some problem in the data (s)he entered there, so this
> > Valid method should prevent him/her from leaving this control... Am I
> right?
> > If so, you may try to use MESSAGEBOX() function for such a
notifications.
> I
> > suppose that WAIT WINDOW (as it is VFP managed window) is less "modal"
> then
> > MESSAGEBOX one, so you can click other controls when it is active, but
> > MESSAGEBOX will prevent you from clicking on anything but this dialog
> > window. As it should be IMHO...

> > WBR, Igor



Tue, 06 Sep 2005 08:30:10 GMT  
 Cannot call set focus from valid ...
Thanks John G. for the tip.

I will dig it up.
But at the moment, the main problem is how to notice
the user, the default Wait Window will sure end up in the basket...

Christophe
Belgium



Quote:
> Hi,
> If you really want to rethink the way you handle messages in your
> application, I suggest reading the section "How can I simplify getting
> messages to my users?" in the book, "1001 Things You Wanted to Know About
> Visual FoxPro" by Hentzenwerke Publishing.  This article shows you how to
> easily develop a table (.dbf) of messages and access those messages with
one
> call.  Very nice.
> John.



> > Igor,

> > Absolutaly right,
> > The MessageBox() did his job very well.
> > But I don't really like it.
> > "My users" are used to see those Wait Window messages
> > and I have tons of it with small messages like "Please enter a value"
> > or just "Wait ..." or "Printing ..." or "Sorry, not available."
> > I only used a MessageBox() when it was more severe
> > like "You really want to delete this ?".

> > I also found, and this is in favour of a messagebox :-(
> > that a Wait Window can't be used in a As top level Modeless form.
> > Well at least it is shown but it pops up the _Screen window !
> > Maybe I will have to rethink the communication with my users.
> > Mayby I could let it talk, this would be cool ...

> > thanks a lot for the time spend.

> > Christophe
> > Belgium



> > > Hi, christophe!
> > > You wrote  on Wed, 19 Mar 2003 16:46:27 +0100:

> > > I assume that if you have WAIT WINDOW in Valid event, then you want to
> > > notify user about some problem in the data (s)he entered there, so
this
> > > Valid method should prevent him/her from leaving this control... Am I
> > right?
> > > If so, you may try to use MESSAGEBOX() function for such a
> notifications.
> > I
> > > suppose that WAIT WINDOW (as it is VFP managed window) is less "modal"
> > then
> > > MESSAGEBOX one, so you can click other controls when it is active, but
> > > MESSAGEBOX will prevent you from clicking on anything but this dialog
> > > window. As it should be IMHO...

> > > WBR, Igor



Tue, 06 Sep 2005 15:43:37 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Lost Focus Event - Setting Focus

2. Grid Valid and Column focus

3. Calling Procedures and Functions - VFP 6.0--When Set Procedure Doesn't Set

4. OLE object form cannot get focus properly...

5. Giving a form focus from calling program

6. Setting focus in a browse

7. Problem with Selecting Text by Setting Focus

8. set focus and refresh.

9. How to set focus to a grid

10. set focus problem...

11. Setting Grid Focus to Next Row VFP5

12. Edit Box field text selected on set focus

 

 
Powered by phpBB® Forum Software