Change Themes to Control Look and Feel

You can use a macro to change the look and feel of a session. You can also programmatically change display elements such as the screen color, font, and cursor. Some examples of changing these elements include:

  • Changing the background color to indicate which program is being used, highlight specific types of information, or indicate a data type (such as the type of dataset).
  • Changing the font size to adjust to changes in screen resolution.  
  • Changing the cursor shape or color to prompt users.
  • Toggling the rule line on or off. 

This sample shows how to load a theme and change the cursor, font, and background color of the session.

This article contains tabbed content that is specific to each terminal type. Be sure the tab for your terminal type is selected.

To run this sample

  1. In a terminal session, open the Visual Basic Editor and insert a module in the session project folder.
  2. Copy the code into the module code window and then press F5 to run the macro.
    Change colors, fonts, and cursor
    Copy Code
    Public Sub ChangeThemeAndfontSize()
     
        'Declare and set a Themefont object
        Dim font As Attachmate_Reflection_Objects_Emulation_IbmHosts.ThemeFont
        Set font = ThisIbmTerminal.Theme.font
      
        'Declare and set a Themecursor object
        Dim cursor As Attachmate_Reflection_Objects_Emulation_IbmHosts.ThemeCursor
        Set cursor = ThisIbmTerminal.Theme.cursor
      
        'Declare and set a Themecolor object
        Dim color As Attachmate_Reflection_Objects_Emulation_IbmHosts.ThemeColor
        Set color = ThisIbmTerminal.Theme.ThemeColor
    
        'Set AutofontSize to false to allow resizing of font
        font.AutoFontSize = False
        font.FONTSIZE = 10
      
        'Set the cursorShape and Blink Rate
        cursor.CursorShape = CursorShapeOption_Underline
        cursor.CursorBlinkRate = CursorBlinkRateOption_Fast
      
        'Make the ruler line visible and set the type to crosshair
        cursor.RulerCursorVisible = True
        cursor.RulerCursorType = RulerCursorTypeOption_Crosshair
        'Set the screen Background color
        color.BackgroundColor = RGB(0, 0, 0)
     
        'Save the changes in a new theme to prevent Reflection from requesting to save new theme
        ThisIbmTerminal.Theme.SaveAs (Environ$("USERPROFILE") & "\Documents\Micro Focus\InfoConnect\Themes\myTheme.themex")
        
    End Sub
    
    Change colors, fonts, and cursor
    Copy Code
    Public Sub ChangeThemeAndfontSize()
     
        'Declare and set a font object
        Dim font As ThemeFont
        Set font = ThisTerminal.Theme.font
      
        'Declare and set a color object
        Dim color As ThemeColor
        Set color = ThisTerminal.Theme.color
      
        'Declare and set a cursor object
        Dim cursor As ThemeCursor
        Set cursor = ThisTerminal.Theme.cursor
        
        'Set AutofontSize to false to allow resizing of font
        font.AutoFontSize = False
        font.FONTSIZE = 10
      
        'Set the screen background color and the text color
        color.SetBackgroundColor TextColorMappingAttribute_Plain, RGB(0, 0, 0)
        color.SetForegroundColor TextColorMappingAttribute_Plain, RGB(255, 255, 255)
      
        'Change to a colored cursor with a faster blink rate and a vertical bar shape
        cursor.Parent.DisplayEnhancements.ColorCursor = True
        cursor.CursorBlink = True
        cursor.CursorShape = CursorShapeOption_VerticalBar
       
        'Save the changes in a new theme to prevent Reflection from requesting to save new theme
        ThisTerminal.Theme.SaveAs (Environ$("USERPROFILE") & "\Documents\Micro Focus\InfoConnect\Themes\myTheme.themex")
           
    End Sub
    

Concepts

The Theme object contains the ThemeFont, ThemeColor, and ThemeCursor objects. You get access to these objects through the Theme object. 

Another approach for changing theme properties is to load an entire theme:

Load a theme
Copy Code
'Load a theme
ThisIbmTerminal.Theme.Load (Environ$("USERPROFILE") & "\Documents\Micro Focus\InfoConnect\Themes\myTheme.themex")
Load a Theme
Copy Code
'Load a theme
    ThisTerminal.Theme.Load (Environ$("USERPROFILE") & "\Documents\Micro Focus\InfoConnect\Themes\myTheme.themex")

You can run these macros automatically when certain screens are recognized or when specific events occur. For example, after a user selects a program, you could indicate which program is running by changing the background color on the first screen of the program. (See Controlling Macro Execution and Using InfoConnect Events.)

See Also

 

 


2015 Attachmate