HowTos > 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:
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. |
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 |
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.)