Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Rick C. Hodgin
  Where is Rick C. Hodgin?
 Indianapolis
 Indiana - United States
 Rick C. Hodgin
 To: Rick C. Hodgin
  Where is Rick C. Hodgin?
 Indianapolis
 Indiana - United States
 Rick C. Hodgin
 Tags
Subject: RE: (Object) has inaccessible members-SOLVED
Thread ID: 365532 Message ID: 365536 # Views: 40 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Errors & Debugging
Date: Thursday, December 27, 2012 8:20:49 PM         
   


This is an example which fails on both form and class, as they are both created by text-based definition. See my next reply for a ZIP file that has three options for failure.

Visual FoxPro is handling GUI-based form instantiation differently than text-based form definitions and container object classes in all cases.




**********
* Save as:  ghost.prg
*****
* To see the effect of objects that were deleted, but remain as ghosts,
* run this code and when it gets to SET STEP ON, you can see the
* comment there.  Examine:
*
*     this.parent.r1c1
*
* You'll see that it still exists, even though none of its members
* are accessible.  Typing type("this.parent.r1c1") in the watch
* window returns "O".  ISNULL("this.parent.r1c1") returns .F..
*
* It's simply in the ghost state.
*
* Create the exact same conditions on a form using the designer, and
* clicking the "X (Form)" object WILL remove the object properly, but
* the class will not.
*
*****

* All classes are defined below
lof = CREATEOBJECT("myForm")
lof.Visible = .t.

READ EVENTS
*CLEAR ALL




* Form definition goes here
DEFINE CLASS myForm AS Form
    WindowType = 0    && Modeless
    ShowWindow = 1    && Top level form
    
    ADD OBJECT controlObject AS controller
    
    ADD OBJECT r1c1 AS contains WITH ;
            Top = 60, ;
            Left = 60, ;
            cmdX.Caption = "X (Form)"
    
    ADD OBJECT aContainer AS myContainer WITH ;
            Left = 200, ;
            Top = 60
    
    PROCEDURE Init
        this.Width = this.aContainer.Left + this.aContainer.Width + this.r1c1.Left
        this.Height = this.aContainer.top + this.aContainer.Height + this.r1c1.Top
    
    PROCEDURE Unload
        CLEAR EVENTS
ENDDEFINE

* Class definition goes here, identical to form's definition
DEFINE CLASS myContainer AS Container
    ADD OBJECT controlObject AS controller
    
    ADD OBJECT r1c1 AS contains WITH ;
            cmdX.Caption = "X (Container)"
    
    PROCEDURE Init
        this.Width = this.r1c1.Width
        this.Height = this.r1c1.Height
ENDDEFINE

* Container for a button
DEFINE CLASS contains AS Container
    ADD OBJECT cmdX AS myCmdX
    
    PROCEDURE Init
        this.Width = this.cmdX.Width
        this.Height = this.cmdX.Height
ENDDEFINE

* The button
DEFINE CLASS myCmdX AS CommandButton
    AutoSize = .t.
     
    PROCEDURE Click
        * Delete this object's parent container from its parent
        this.Parent.Parent.controlObject.mth_delete(this.Parent.Name)
ENDDEFINE

* Support class (handles various things on forms/common classes)
DEFINE CLASS controller AS label
    Caption = "controller"
    Visible = .f.
    
    PROCEDURE mth_delete
    LPARAMETERS tcName
        IF TYPE("this.Parent." + tcName) = "O"
            this.Parent.RemoveObject(tcName)
            
            * Examine "this.Parent.&tcName" in the debugger
            * Examine "this.Parent.r1c1" in the debugger (same thing)
            SET STEP ON
        ENDIF
ENDDEFINE


Best regards,
Rick C. Hodgin

ENTIRE THREAD

(Object) has inaccessible members-SOLVED Posted by Rick Hodgin @ 12/27/2012 7:09:51 PM
RE: (Object) has inaccessible members-SOLVED Posted by Rick Hodgin @ 12/27/2012 8:20:49 PM
RE: (Object) has inaccessible members-SOLVED Posted by Rick Hodgin @ 12/27/2012 9:12:03 PM