Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Properties 'Exit' is not found 1

Status
Not open for further replies.

sohrab100

Programmer
Jan 18, 2002
56
HK

Description: Exit is a UserDefine Method in a Form

My Code

On key label f2 _screen.activeform.exit

Sometime, my client report that they face "Properties 'Exit' is not found", it is related to "EXIT" is a reserved word?
So are there any difference with the command below:

On key label f2 _screen.activeform.exit()

Since Book Tell me no need to include bracket.




sohrab100
 
I would say chance are the problem is because Exit is a reserved word. Why don't you try renaming the method to something else? FWIW, I always include the parentheses when calling methods, just for clarity's sake.



-BP
 
HI

You can rename the method 'Exit' to 'ExitForm' and change your activate event code to ExitForm.

If you would want to know, where all you have used Exit in your code, try using the code to extract all events and methods codes using the FAQ code from..

Collection of all methods and Events code in Forms
faq184-2948

and

Collection of PRGs - all code in one window
faq184-2947

If you are using VFP8, finding the code is even more simpler..
VFP Menu->Tools->Code references and key in Exit and search.

:)

____________________________________________
Ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
sohrab100,

Although I totally agree with Barbara and Ramani about Exit being a reserved word, I think the most likely reason for this message is that there is no form open at the time the user hits F2.

Because there is no form open, there is no ActiveForm, so that form cannot have an Exit property.

Mike


Mike Lewis
Edinburgh, Scotland
 
The Actual Case is

Form1

Activate Event:
On key Label F2 _screen.activeform.exit

Form1 has an user define Exit Method

So, when someone press F2, it should be in Form1 screen and _screen.activeform will resolve to Form1 and should call the EXIT Method. Am I right?

So, Mike, what is your suggestion on it?

sohrab100
 
sohrab100,

The scenario you described could still result in a situation where _SCREEN.ActiveForm does not exist.

Even without the error that you saw, my suggestion would be to avoid using ON KEY LABEL. The problem with it is that you have no control over its timing, and you could get code being run "out of context".

I think it would be much better to call your Exit method from the form's Keypress event (you will also need to set its Keypreview to .T.). That way, it can only fire when the form is active.

Also, if you want consistent behaviour in all your forms, you can put the code in the Keypress at the form class level.

Let me know if this helps.

Mike


Mike Lewis
Edinburgh, Scotland
 
sohrab100,

Mike's right. You'd be better off putting this in the form's Keypress method. Just make sure you set the form's KeyPreview property to .T., so that it doesn't fire the KeyPress of one of your form's objects instead.

Also, since the Exit method is within the current form, it would make more sense to use THISFORM instead of _SCREEN.ActiveForm.



-BP
 
Mike, when i set keypreview to .t., I have a problem for my application.
I have a list on top and some entry box (editbox,textbox) at the bottom, I have the event of uparrow/downarrow key to navigate the list, but when i press up/down arrow key and the entry box are in focus, the entry box movefocus from one to another entry box, so can i do anything to avoid movement of focus in entry box by up/down arrow key?
PS: I Don't have any keypress event for up/down arrow key in all of the entry box.



sohrab100
 
sohrab100.

Check this FAQ out concerning ON KEY LABEL and KeyPress Event on a form.

faq184-4097 KEYPRESS Event instead of ON KEY LABEL

Jim Osieczonek
Delta Business Group, LLC
 
Thanks Jim, but it's not the case I want to ask. The foundation of Keypress event I understood.

The Screen Like
-----------------------------------------

UserDefined Object - List of Record
--------------------------------
| Record 1 |
--------------------------------
| Record 2 |
--------------------------------

------------ ------------
| Editbox1 | | Editbox2 |
------------ ------------

-------------------------------------------
up/down arrow: navigate the list
Tab: navigat the EditBox1 --> EditBox2

When i use on key label, it work fine.
But when i use keypress event, the up/down arrow press will do the following action:

1. navigate the list
2. navigate the EditBox from one to other
e.g Down arrow : EditBox1 -> EditBox2 when EditBox1 in focus.

But it will not happen in On Key Label. It only navigate the list up and down when up/down arrow key press.
Am I describe clearly?



sohrab100
 
sohrab100,

You need to call DODEFAULT if the key isn't one you want to process. Your Keypress method should look like this:
Code:
IF nKeyCode = -1
   Thisform.ExitForm()
ELSE
   DODEFAULT
ENDIF



-BP
 
Hi Barbara,

1. In a KeyPressEvent..
DODEFAULT() is implied. There is no need to expressly say that. NODEFAULT will not carry out the default functionality.

2. DODEFAULT always needs DODEFAULT().. the ending ()...
else it will show error.
I am sure this you know very well,and it si only a type here. But only to set it correct for the readers, I put this here.
:)
******************************************
Sohrab

In the forms keypress event, you can avoid the processing of the keypress code.. by the code..

IF UPPER(ThisForm.ActiveControl.BaseClass)

IF UPPER(ThisForm.ACtiveControl.BaseClass) $ ;
"TEXTBOX,COMMANDBUTTON,whateverControls"
** DO FURTHER PROCESSING
** OR... NODEFAULT
ELSE
** DO FURTHER PROCESSING
** OR... NODEFAULT
ENDIF
This will solve the issue of wanting the keypress do something while in some controls only.

:)

____________________________________________
Ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Hi Ramani,

DODEFAULT always needs DODEFAULT().. the ending ()...
else it will show error.[/]

Oops. Yeah that was a typo. Thanks for catching that.

In a KeyPressEvent..
DODEFAULT() is implied. There is no need to expressly say that. NODEFAULT will not carry out the default functionality.


Knowing how inheritance works you would think so, but the case of the KeyPress method, I've run into odd behavior. I don't remember the specifics, but I've gotten into the habit of always having a DODEFAULT() in the KeyPress when I add code.

BTW, in trying to see if I could remember the circumstances, I was testing this out in a small form, and I couldn't get the KeyPress method to recognize an nKeyCode of -1 at all. I remember having a problem like this on my previous machine, and it turned out to be something in the BIOS setting. I'm not going to check my BIOS right now, but if sohrab100 or anyone else has problems getting the KeyPreview to recoginize function keys, this is one thing to check. (After you've checked that you don't have any menu hot keys that are taking precedence.)



-BP
 
Barbara,

I really need to get in the habit of previewing my messages before sending them

You'll soon get the hang of typing the tags -- it took me about two weeks -- and it'll become second nature.

My only problem is when I want to put the literal tags in a message, to explain to someone what tags to use. It took me a while to find the [ignore][ignore][/ignore] tag.

Mike


Mike Lewis
Edinburgh, Scotland
 
Oops. I just disproved my own assertion. I should've previewed that.

That y with an umlaut on it -- it should've been the word ignore in square brackets. Don't aks me how that happened.

Mike


Mike Lewis
Edinburgh, Scotland
 
Mike, one more thing to ask is that the "Property "Exit" is not found" is found due to inactive of current form. But the case is when user Switch to other application (ALT-Tab) and switch back to my application, in rarely case that sometime will out focus of the form and cannot be focus again. That is the strange.

So, I can only solve not prompt "Property "Exit" is not found" by putting the exit code in KeyPress Event, but the application look like hang (cannot be focus by mouse or keyboard, but i sure that it's working, not hang) because the application cannot capture the Exit event due to inactive of form.

So, the main problem is application sudden inactive, therefore, all function use on key label _screen.activeform.xxxx will prompt error and all function use keypress event will no response, any idea?


sohrab100
 
HI Barbara

Yes, it is a good practice to code.. DODEFAULT() and NODEFAULT explicitly, I agree.

Knowing how inheritance works you would think so, but the case of the KeyPress method, I've run into odd behavior...

I pointed out, only because, I felt you are saying it to mean that inserting NODEFAULT will solve the problem under question and for this KeyPress event.

The DODEFAULT() will fire, when left out, is not always the default behaviour of every event. In almost all events code, the presence of even a single space without any other code, will disable the call to the parent class code. So DODEFAULT() is essential in many events to call the parent code.

The exceptions are the ones like KeyPressEvent. The reason is that the KeyPress is revolving around the windows function of keypress.

Again nKeyCode = -1 will not function in keypress event. Same way, with HELP ON, F1 cannot be trapped. The reason is that Windows defalt behaviours or the VFP engines behaviour takes over first and gets fired even before the applications call is captured.

:)

____________________________________________
Ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Sohrab100

.. one more thing to ask is that the "Property "Exit" is not found" is found due to inactive of current form. But the case is when user Switch to other application (ALT-Tab) and switch back to my application, in rarely case that sometime will out focus of the form and cannot be focus again. That is the strange.

That is not strange. You have the answer pinpointed.

The form is not in focus. Only the user assumes that they have done Alt+Tab to get the focus to the form. Infact, the focus is on some other object behind the form probably or elsewhere.

One possibility to force user to give the focus, could be.. to make them click the form. SO in effect, in the Forms, lost focus event, if you insert the code..
ThisForm.WIndowState = 1 && minimised..

They will be forced to set the focus back by clicking on the minimized form.

Otherwise, it is almost not possible to force the focus to the form when the user "THINKS" that the form is in focus, rather than his/her act corrdinated with the action. We havent got into that advancement.

:)

____________________________________________
Ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 

MikeLewis

My only problem is when I want to put the literal tags in a message, to explain to someone what tags to use. It took me a while to find the ÿ tag.


Use the [ i g n o r e] tags (no spaces). I use them to show internet links so they don't get cut off.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top