Skip to content

CommandBarSystemObject - cCJContextMenu

Returns the handle of the cCJCommandBarSystem that this context menu uses

Type: Function
Return Data Type: Handle

Syntax

Function CommandBarSystemObject Returns Handle

Call Example

Get CommandBarSystemObject to HandleVariable

Description

CommandBarSystemObject can be called by any commandbar object to find the commandbar system object that owns it. This returns the handle of the cCJCommandBarSystem object that owns it. With most menubar and toolbar objects (e.g., cCJMenuItem, cCJAction, cCJMenuBar, cCJToolBar) this message is resolved via delegation. These objects delegate to a parent object that understands this message, which returns a handle. In these cases, this parent object is the cCJCommandBarSystem object and the CommandBarSystemObject returned is its own object handle.

Context menus are the exception.

Context menus will rarely be nested within a cCJCommandBarSystem object. When a cCJContextMenu object processes this method it must find a cCJCommandBarSystem object it can use and return that handle. All objects within the context menu (e.g. cCJMenuItem) will delegate this request to the context menu object as well.

By default, context menus return the handle of the global commandbar system object. This is the menu/toolbar system that is defined as your main MDI commandbar system. If such an object does not exist, the context menu cannot be used. Therefore, an alternate method of determining the commandbar system is provided. You can explicitly set the phoCommandBars property to an active commandbar system object. If you do that, that handle will be returned and used.

You should always use CommandBarSystemObject to find the commandbar system object. If a developer always uses the CommandBarSystemObject to determine a menu item's commandbar system the same objects and classes can be used for menubar / toolbar items and in context menu items.

Class cCJStatusbarMenuItem is a cCJMenuItem

    Procedure Construct_Object
        Forward Send Construct_Object
        Set psCaption to C_$CaptionAddStatusbar
        Set psToolTip to C_$ToolTipAddStatusbar
        Set psDescription to  C_$DescAddStatusbar
    End_Procedure

    Procedure OnExecute Variant vCommandBarControl
        Handle hoCommandBars hoClientArea
        Get CommandBarSystemObject to hoCommandBars
        Get ClientAreaObject of hoCommandBars to hoClientArea
        If hoClientArea Begin
            Send Toggle_StatusBar of hoClientArea
        End
    End_Procedure

     Function IsChecked Returns Boolean
        Boolean bOn
        Handle hoCommandBars hoClientArea
        Get CommandBarSystemObject to hoCommandBars
        Get ClientAreaObject of hoCommandBars to hoClientArea
        If hoClientArea Begin
            Get StatusBar_State of hoClientArea to bOn
        End
        Function_Return bOn
     End_Function
End_Class

Return Value

Returns the object handle of the cCJCommandBarSystem object that "owns" this context menu