Code:
Option Strict OffImports NXOpen
Imports NXOpen.Drawings
Imports NXOpen.UF
Module GUI_IN_NX
Dim theSession As Session = Session.GetSession()
Dim theUFSession As UFSession = UFSession.GetUFSession()
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow()
Sub Main(ByVal args() As String)
Dim strPrompt As String = "Test"
Dim strChoices() As String = {"option1", "option2", "option3", "option4", "option5", "option6", "option7", "option8"}
Dim resp As Integer
Dim z(13) As Integer
msgbox(ChooseOneString(strPrompt, strChoices))
theUFSession.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
resp = theUFSession.Ui.DisplayMultiSelectMenu(strPrompt, 0, strChoices, strChoices.Length, z)
theUFSession.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
msgbox(resp)
theUFSession.Ui.DisplayNonmodalMsg("text1", "text2", 2)
End Sub
Function ChooseOneString(ByRef prompt As String, ByRef choices() As String) As String
If choices.Length = 0 Then Return Nothing
Dim opts(13) As String
Dim a As Integer = 0
Dim ii, resp, z As Integer
Dim n_choices As Integer = choices.Length
Do
If (n_choices - a) < 14 Then
z = n_choices - a
Else
z = 14
End If
For ii = 0 To z - 1
opts(ii) = choices(a + ii)
Next
If ((z = 14) And ((a + z) < n_choices)) Then opts(13) = "More..."
theUFSession.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
resp = theUFSession.Ui.DisplayMenu(prompt, 0, opts, z)
theUFSession.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
Select Case resp
Case 1 ' Back
If (a = 0) Then Return Nothing
a = a - 13
Case 2 ' Cancel
Return Nothing
Case 18 ' More ...
If ((a + z) < n_choices) Then a = a + 13
Case Else ' Picked one
Return choices(a + resp - 5)
End Select
Loop While True
Return Nothing ' can't really get here
End Function
End Module