InfoConnect VBA Guide
HowTos / Change Themes to Control Look and Feel
In This Topic
    Change Themes to Control Look and Feel
    In This Topic

    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:

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

    If you prefer to run macros in pre-configured sessions instead of creating your own sessions, you can download the VBA Sample Sessions and open the change-themes.rd3x (IBM) and change-themes.rdox files (Open Systems). The download package contains everything you need to run the macros in these files. See Download the VBA Sample Sessions.

    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.
      This article contains tabbed content that is specific to each terminal type. Be sure the tab for your Which Terminal Type are you Using? is selected.

      Change colors, fonts, and cursor
      Copy Code
      Public Sub ChangeLookAndFeel()
       
          'Declare and set a Themefont object
          Dim font As Attachmate_Reflection_Objects_Emulation_IbmHosts.ThemeFont
          Set font = ThisIbmTerminal.Theme.font
                                     
        
          '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
          cursor.CursorShape = CursorShapeOption_Underline
      
          '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 InfoConnect 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
      'This macro changes the screen color, font size, and cursor shape.
      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
       
          'Change to a cursor with a vertical bar shape
          cursor.Parent.DisplayEnhancements.ColorCursor = False
          cursor.CursorShape = CursorShapeOption_Block
          'Change the screen foreground and background colors
          'First, get the integer that is associated with the screen foreground and background colors
          foregroundColorInt = color.GetForegroundColorAsInt(TextColorMappingAttribute_Plain)
          backgroundColorInt = color.GetBackgroundColorAsInt(TextColorMappingAttribute_Plain)
       
          'Then set the screen foreground and background colors by changing the color map
          color.SetColorRGB foregroundColorInt, 250, 250, 200
          color.SetColorRGB backgroundColorInt, 150, 150, 120
        
          'Save the changes in a new theme to prevent InfoConnect 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