main logo
Subject: Problem with NEW button and MPR's
Author: James H. Hansen
Posted: 2001/07/06 20:07:20
 
View Entire Thread
New Search


I am trying to use MPR's instead of object menues with a new CB 6.1 project and have run into a problem with the NEW button on toolbars. Seems it's <i>Refresh</i> method attempts to access <i>_SCREEN.ActiveForm</i> resulting in the following error message:
<font color=ff0020>
Error #: 1924
Message: PARENT is not an object.
Line #: 41
Code: IF FormIsObject( _SCREEN.ActiveForm )
Method: refresh
Object: cmdNew
</font>
First, the reference to <i>PARENT</i> is totally bogus. The error is that <i>_SCREEN.ActiveForm</i> is aparently <u>undefined</u> until the form's INIT is completed. Is this a problem with CB 6.1 and object menus as well?

The code was changed from CB 6.0 which was:
<font color=0000ff>
IF TYPE("_screen.ActiveForm.lAllowNew") <> "U"
this.SetEnabled(_screen.ActiveForm.lAllowNew)
ENDIF
</font>
to CB 6.1's code:
<font color=0000ff>
IF FormIsObject( _SCREEN.ActiveForm )
IF PEMSTATUS( _screen.ActiveForm, "lAllowNew", 5 ) = .T.
THIS.SetEnabled(_screen.ActiveForm.lAllowNew)
ENDIF
ENDIF
</font>
I temporarily overrode this in the <i>i</i>-level button with:
<font color=0000ff>
IF type("_SCREEN.ActiveForm") # "U" and FormIsObject( _SCREEN.ActiveForm )
IF PEMSTATUS( _screen.ActiveForm, "lAllowNew", 5 ) = .T.
THIS.SetEnabled(_screen.ActiveForm.lAllowNew)
ENDIF
ENDIF
</font>
A similar problem also comes up in the Refresh and Save buttons, and possibly others.

As an aside: This is the second time I've gotten an error message about <i>PARENT</i> when the problem was with something related to <i>_SCREEN</i>. (See #6338) Is this a pattern? Something in CodeBook error handling or in VFP?
Jim Hansen
Canyon Country Consulting
 
©2001 James H. Hansen
<-- Prior Message New Search Next Message -->