Skip to content

ExchangeLayout - cCJCommandBarSystem

Exchanges the layout of the CommandBarSystem and a cCJPropExchange object

Type: Procedure

Parameters

Parameter Type Description
hoExchange Handle Handle to the cCJPropExchange object
sSection String Name of the section where the data will be exchanged
eLayout Integer Determines what data is exchanged. Possible values are:ConstantMeaning

Syntax

Procedure ExchangeLayout Handle hoExchange String sSection Integer eLayout

Call Example

Send ExchangeLayout hoExchange sSection eLayout

Description

ExchangeLayout exchanges the layout of the cCJCommandBarSystem object and a cCJPropExchange object. The exchange object is used to move layout information in and out of registry and XML files.

Normally, the saving and restoring of layout data is handled automatically (see: peRestoreLayout, SaveEnvironment, LoadEnvironment). This method is exposed for advanced usage when a developer wishes to control the saving and restoring of commandbar data as part of an exchange of other types of layout information. The direction of the data exchange is controlled by the property exchange object's (ComLoading) property.

If you send this method yourself, you will probably disable normal loading/saving by setting peRestoreLayout to rlNoSaveRestore. You would then create the property exchange object and set the various properties in this object to determine what is being saved and loaded. You would call ExchangeLayout to exchange the information between the commandbar system object and the exchange object.

The use of this method can be complicated. Before using this you must have a good understanding of how the cCJPropExchange object is used. This same object can be used to exchange information from other Codejock controls. You advised to look at source code for the methods SaveLayoutToRegistry, SaveLayoutToXML, LoadLayoutFromRegistry and LoadLayoutFromXML to see how this may be used.

Sample

Procedure SaveLayoutToRegistry Integer eLayout String sKey 
        Handle hoExchange hoRegistry
        Boolean bOk bExists bVoid
        String sSection sFullKey sShortKey

        If (eLayout=rlNoSaveRestore) Begin
            Procedure_Return
        End

        Move ("HKEY_CURRENT_USER\" - sKey) to sFullKey
        Get psLayoutSection to sSection
        Move (sKey - "\" - sSection) to sShortKey

        If (sKey="" or sSection="") Begin
            Error DFERR_PROGRAM "Assert: Registry Key or Section name is invalid"
        End

        Get CreatePropExchangeObject to hoExchange
        Get ComCreateAsRegistry of hoExchange False sFullKey to bOk

        If Not (bOk) Begin
            Error DFERR_PROGRAM "Assert: Cannot save layout to registry"
        End

        If bOk Begin
            // delete the existing registry information for this section
            Get Create U_cRegistry to hoRegistry
            Set pbLazyWrite of hoRegistry to False
            Get KeyExists of hoRegistry sShortKey to bExists
            If bExists Begin
                Get DeleteKey of hoRegistry sShortKey to bVoid
            End
            Send Destroy of hoRegistry

            Send ExchangeLayout hoExchange sSection eLayout
        End

        Send Destroy of hoExchange
   End_Procedure