Difference between revisions of "Method globalCustomUIs"

From Ribbon Commander Documentation
Jump to: navigation, search
(Remarks)
(Remarks)
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
== Description ==
 
== Description ==
Static method that returns the {{collection}} of [[rxCustomUI]]s with global dispatch in the current session.
+
(VBA-specific) Static method that returns the {{collection}} of [[rxCustomUI]]s with [[rxDispatchScope | global dispatch]] in the current session.
  
 
== Parameters ==
 
== Parameters ==
Line 7: Line 7:
  
 
== Remarks ==
 
== Remarks ==
# The default [[rxCustomUI]] of the session (see [[Method defaultInstance|rxCustomUI.defaultInstance]]) is a read-only member of the collection.
+
# The default [[rxCustomUI]] of the session (see [[Method defaultInstance|rxCustomUI.defaultInstance]]) is a read-only member of the collection (i.e. it can't be removed).
 
# [[rxCustomUI]] objects are added to the collection via method [[Method create|rxCustomUI.create]] when [[rxDispatchScope | DispatchScope_global]] is used.
 
# [[rxCustomUI]] objects are added to the collection via method [[Method create|rxCustomUI.create]] when [[rxDispatchScope | DispatchScope_global]] is used.
# For examples on how to manipulate the collection see [[IrxGlobalCustomUI_VBA_col]]
+
# You can look-up [[rxCustomUI]] objects in the {{collection}} by contextId (see [[#Examples|Examples]]).
  
 
== Examples ==
 
== Examples ==
Line 15: Line 15:
 
=== VBA ===
 
=== VBA ===
 
<syntaxhighlight lang="vb" line>
 
<syntaxhighlight lang="vb" line>
' Cache a reference to the default rxCustomUI of this session
+
Public Sub TestGlobalCustomUIs()
Dim myCustomUI As rxCustomUI
+
   
Set myCustomUI = rxCustomUI.defaultInstance
+
    ' We are assuming that no rxCustomUI objects with global dispatch have
</syntaxhighlight>
+
    ' been created in this session yet
 
+
   
=== C# ===
+
    ' Print the number of global rxCustomUIs
<syntaxhighlight lang="csharp" line>
+
    ' Prints 1; it's the session's default rxCustomUI (see rxCustomUI.defaultInstance)
// Cache a reference to the default rxCustomUI of this session
+
    Debug.Print rxCustomUI.globalCustomUIs.Count
rxCustomUI myCustomUI = rxCustomUI.defaultInstance
+
   
</syntaxhighlight>
+
    ' Create a new rxCustomUI with global dispatch scope.
 
+
    ' The rxCustomUI gets added to the global rxCustomUI collection uppon creation
=== VB.NET ===
+
    Dim myCustomUI As rxCustomUI
<syntaxhighlight lang="vb" line>
+
    Set myCustomUI = rxCustomUI.Create("my_context", "My Test UI", DispatchScope_global)
' Cache a reference to the default rxCustomUI of this session
+
   
Dim myCustomUI As rxCustomUI = rxCustomUI.defaultInstance
+
    ' Print the number of global rxCustomUIs (prints 2)
</syntaxhighlight>
+
    Debug.Print rxCustomUI.globalCustomUIs.Count
 
+
   
=== C++ ===
+
    ' Remove the rxCustomUI obj from the globals collection. Its lifetime is now tied to
<syntaxhighlight lang="cpp" line>
+
    ' the scope of this function
 +
   
 +
    ' Lookup the customUI by contextId
 +
    Dim myCustomUI2 As rxCustomUI
 +
    Set myCustomUI2 = rxCustomUI.globalCustomUIs("my_context")
 +
   
 +
    ' Remove the obj from the collection
 +
    rxCustomUI.globalCustomUIs.Remove myCustomUI2
 +
   
 +
    ' Print the number of global rxCustomUIs (prints 1)
 +
    Debug.Print rxCustomUI.globalCustomUIs.Count
 +
   
 +
End Sub
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 22:22, 14 March 2013

Description

(VBA-specific) Static method that returns the collection of rxCustomUIs with global dispatch in the current session.

Parameters

Parameter Name
Parameter Type
Default Value
Description

Remarks

  1. The default rxCustomUI of the session (see rxCustomUI.defaultInstance) is a read-only member of the collection (i.e. it can't be removed).
  2. rxCustomUI objects are added to the collection via method rxCustomUI.create when DispatchScope_global is used.
  3. You can look-up rxCustomUI objects in the collection by contextId (see Examples).

Examples

VBA

  1. Public Sub TestGlobalCustomUIs()
  2.  
  3.     ' We are assuming that no rxCustomUI objects with global dispatch have
  4.     ' been created in this session yet
  5.  
  6.     ' Print the number of global rxCustomUIs
  7.     ' Prints 1; it's the session's default rxCustomUI (see rxCustomUI.defaultInstance)
  8.     Debug.Print rxCustomUI.globalCustomUIs.Count
  9.  
  10.     ' Create a new rxCustomUI with global dispatch scope.
  11.     ' The rxCustomUI gets added to the global rxCustomUI collection uppon creation
  12.     Dim myCustomUI As rxCustomUI
  13.     Set myCustomUI = rxCustomUI.Create("my_context", "My Test UI", DispatchScope_global)
  14.  
  15.     ' Print the number of global rxCustomUIs (prints 2)
  16.     Debug.Print rxCustomUI.globalCustomUIs.Count
  17.  
  18.     ' Remove the rxCustomUI obj from the globals collection. Its lifetime is now tied to
  19.     ' the scope of this function
  20.  
  21.     ' Lookup the customUI by contextId
  22.     Dim myCustomUI2 As rxCustomUI
  23.     Set myCustomUI2 = rxCustomUI.globalCustomUIs("my_context")
  24.  
  25.     ' Remove the obj from the collection
  26.     rxCustomUI.globalCustomUIs.Remove myCustomUI2
  27.  
  28.     ' Print the number of global rxCustomUIs (prints 1)
  29.     Debug.Print rxCustomUI.globalCustomUIs.Count
  30.  
  31. End Sub