setfocus in keypress of form causes form to not close 
Author Message
 setfocus in keypress of form causes form to not close

When attempting to move focus from one control to another using setfocus in
the keypress event of the form, the form is no longer able to be freed.  I
guess the inner peace of Foxpro has been corrupted :(

Does anyone have a workaround for this?



Sat, 17 Apr 2004 12:50:59 GMT  
 setfocus in keypress of form causes form to not close
Hey Brett,

Just did a couple simple things and couldn't reproduce.  Can you give a few
more specifics, e.g., what kind of code is in the KeyPress and if KeyPreview
is on for starters?

Quote:
> I guess the inner peace of Foxpro has been corrupted :(

Have you suggested this as alternative text for the C...05 error message?

- John



Sat, 17 Apr 2004 23:07:21 GMT  
 setfocus in keypress of form causes form to not close
Hey Brett,

Just did a couple simple things and couldn't reproduce.  Can you give a few
more specifics, e.g., what kind of code is in the KeyPress and if KeyPreview
is on for starters?  Also, how are you trying to close it (via the close
button on the titlebar or a button's click)?

Quote:
> I guess the inner peace of Foxpro has been corrupted :(

Have you suggested this as alternative text for the C...05 error message?

- John



Sat, 17 Apr 2004 23:09:02 GMT  
 setfocus in keypress of form causes form to not close
Please let me retract this post....
I think it was a selfmade problem :)


Quote:
> When attempting to move focus from one control to another using setfocus
in
> the keypress event of the form, the form is no longer able to be freed.  I
> guess the inner peace of Foxpro has been corrupted :(

> Does anyone have a workaround for this?



Sat, 17 Apr 2004 13:40:00 GMT  
 setfocus in keypress of form causes form to not close
Found the problem - Me 1, Foxpro 0!

The problem lies in the following code

LPARAMETERS nKeyCode, nShiftAltCtrl
LOCAL ActiveControl
IF nkeycode = 13
 ActiveControl = ThisForm.ActiveControl
 IF ActiveControl = ThisForm.Grid1 or ActiveControl.Parent = ThisForm.Grid1
  ThisForm.Text1.SetFocus
 ELSE
  ThisForm.Grid1.SetFocus
 ENDIF
 nodefault
endif

If the following comparison is removed :ActiveControl.Parent =
ThisForm.Grid1
The form works fine.

To recreate : simply add a grid and a textbox to the form, and insert the
code into the keypress event of the form (and set keypreview to .t.)


Quote:
> Hey Brett,

> Just did a couple simple things and couldn't reproduce.  Can you give a
few
> more specifics, e.g., what kind of code is in the KeyPress and if
KeyPreview
> is on for starters?  Also, how are you trying to close it (via the close
> button on the titlebar or a button's click)?

> > I guess the inner peace of Foxpro has been corrupted :(

> Have you suggested this as alternative text for the C...05 error message?

> - John



Sun, 18 Apr 2004 05:48:54 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Printing Report causes VFP form to close (not in FPW

2. Form not closing when clicking on the [X] button on the form

3. MODI FORM causes ...Illegal operation and will be closed error

4. Form:keypress Enter keypress processing

5. error messag, This.cmd2.setfocus() calling form 2 form form1

6. Treeview control and form not closing/Invalid pagefault

7. Closing a form that is not visible, any idea's

8. FORM WITH GRID DOES NOT CLOSE

9. FORM DOES NOT CLOSE

10. Pressing ESC on form does not close

11. Q : Can a form close another form ?

12. Opening and closing forms from within a form.

 

 
Powered by phpBB® Forum Software