Method create

From Ribbon Commander Documentation
Jump to: navigation, search

Description

Static factory method for rxCustomUI objects.

Parameters

Parameter Name
Parameter Type
Default Value
Description
contextId string null The context's unique string identifier
description string 'Ribbon Commander' The context's description
dispatchScope rxDispatchScope DispatchScope_local (VBA-specific) The context's dispatch mode
customUIMode rxCustomUIMode CustomUIMode_dynamic The context's mode

Remarks

  1. A new context is created if it doesn't already exist. If it does exist, the newly created rxCustomUI object joins the existing context.
  2. Parameter description only takes effect when a new context is created.
  3. Parameter customUIMode should be set to CustomUIMode_dynamic (the default value) for smoother UI rendering.
  4. (VBA-specific) Whenever an rxCustomUI with global dispatch is created it is added the 'Global Contexts' collection and doesn't get destroyed until explicitly removed from that collection (i.e. it doesn't get destroyed when Stop is pressed in the VBA editor or when unhandled exceptions are encountered).
  5. (VBA-specific) Whenever an rxCustomUI with local dispatch is created, the lifetime of the context is tied to the lifetime of the rxCustomUI (or rxCustomUI's) in the context. i.e. When the last rxCustomUI of the context is destroyed, the context is also destroyed.

Examples

VBA

  1. ' Create an rxCustomUI with global dispatch
  2. ' A new context is created at this point
  3. Dim myCustomUI As rxCustomUI
  4. Set myCustomUI = rxCustomUI.create("my_sample_context", "My Global Context", DispatchScope_global)
  5.  
  6. ' Create a second rxCustomUI in the same context but with local dispatch
  7. ' The specified context already exists, so the created rxCustomUI joins the existing context
  8. Dim myCustomUI2 as rxCustomUI
  9. Set myCustomUI2 = rxCustomUI.create("my_sample_context", "My Global Context", DispatchScope_local)
  10.  
  11. ' NOTE: Both objects now have access to the same state
  12. ' NOTE2: Notice that the dispatch scope is a property of rxCustomUI; not its context. i.e. rxCustomUIs 
  13. ' with different dispatch scopes belong to the same context above.
  14. _

C#

  1. // Create a new rxCustomUI in context 'cs_ribbon_context'
  2. // The context doesn't exist at this point so it will get created
  3. rxCustomUI myCustomUI = rxCustomUI.create("cs_ribbon_context", "C# Ribbon");
  4.  
  5. // Create another rxCustomUI in context 'cs_ribbon_context'
  6. // The context already exitsts at this point, so the new rxCustomUI will
  7. // just join that context
  8. rxCustomUI myCustomUI2 = rxCustomUI.create("cs_ribbon_context", "C# Ribbon");

VB.NET

  1. ' Create a new rxCustomUI in context 'vb_ribbon_context'
  2. ' The context doesn't exist at this point so it will get created
  3. Dim myCustomUI As rxCustomUI = rxCustomUI.create("vb_ribbon_context", "VB.NET context")
  4.  
  5. ' Create another context in context 'vb_ribbon_context'
  6. ' The context already exists at this point, so the new rxCustomUI will
  7. ' just join that context
  8. Dim myCustomUI2 As rxCustomUI = rxCustomUI.create("vb_ribbon_context", "VB.NET context")

C++

  1.