Dynamically Changing the User Interface
You can dynamically show or hide controls on the user interface to provide a customized user experience. You can also enable or disable controls and change the actions that are mapped to controls.
You can manipulate any control that is configured with the UI Designer. Reflection does not provide programmatic access to other controls.
Before you open Visual Basic, you'll need to identify the controls you want to access in the Reflection UI Designer.
First you will need to open the Reflection workspace and then open the UI Designer, on the Appearance tab.Then add custom controls or select the controls you want to access. In our example, we'll add a tab with a button to the designer.

Note that the Identifier for the tab (tab14). We'll need this ID to identify the control when we access it from the API.
We'll also need the ID for the button. To get this ID, select the button on the UI designer.

Now we have a tab with an Identifier of "tab14" and a button with an Identifier of "button16."
Now, in the Visual Basic editor, create a handler for the Screen Ready event:
Private Sub IbmScreen_NewScreenReady(ByVal sender As Variant)
Dim ui As UiMode
Dim control As UiControl
Set ui = ThisView.UiMode
Set control = ui.GetControlById("tab14")
ScreenID = Trim(ThisIbmScreen.GetText(1, 1, 20))
If ScreenID = "LOGON TST" Then
control.Visible = True
End If
End Sub
To dynamically ad an action to the button, we can call a subroutine in the test for the screen ID:
If ScreenID = "LOGON TST" Then
control.Visible = True
Call UiControlAction_AddAction
End If
Sub UiControlAction_AddAction()
Dim ui As UiMode
Dim control As UiControl
Dim action As New InputMapAction
Dim actionSequence As New InputMapActionSequence
Set ui = ThisView.UiMode
ctrlId = "button16"
Set control = ui.GetControlById(ctrlId)
action.ActionId = InputMapActionID_SendHostTextAction
action.AddParameter "Data"
actionSequence.Add action
ThisIbmTerminal.UiControlActionMapper.Add control, actionSequence
End Sub
|