Returning the parent of an objectΒΆ

parent()

Return the parent of an object


SYNTAX

parent(object_id)

Returns the object_id of the parent of the object specified in the function call. If the specified object has no parent, returns a null object.

The return value should be assigned to a pointer type temporary field, which may be used to reference the parent object.


EXAMPLE

  1. The field tmp.WinPtr may now be used to represent the parent of window Win3:

    !temp WinPtr, p
    
         tmp.WinPtr = &parent(Win3)
    
  2. Retrieve the ultimate parent of a multi button:

    !function MultiButtonEvent(evcode, but) {
    !temp WinPtr,,p
    
         tmp.WinPtr = &parent(parent(but))      /* The first parent is the group */
         info "Window is " + nameof(tmp.WinPtr)
    }
    
  3. Find out if a window has a parent:

    !function TestParentWin(Win) {
    !temp WinParent,,p
    
         WinParent = &parent(Win)
         if (isnull(WinParent) = FALSE) {  /* Window has a parent, so centre it within parent */
              statements
         }
         if (isnull(WinParent) = TRUE) {  /* Window has no parent */
              statements
         }
         return
    }
    

RELATED TOPICS

first_child()

first_control()

fromname()

longname()

nameof()

parent = clause