GUI ScreenIO for Windows

 ScreenIO.com


Changing Colors at Runtime

Once you have defined your named colors in the panel editor, it's easy to change the color of a control in your program.  All you do is move the named color to the control's color attribute.  

If you're using a listview control, you move the named color to the item color field in the listview buffer when you load the item to the listview.  

The colors defined in our sample will appear like this in your panel copybook:  

*                           :-------------------------------------
*                           : Named Colors: (Do NOT change these).
*                           : These serve as sources for MOVE
*                           : statements. You define these color
*                           : combinations in the panel editor
*                           : and use them at runtime to change
*                           : the colors of controls. EXAMPLE:
*                           : MOVE panel-CREDIT-COLOR TO
*                           : CUSTOMER-BALANCE-C.
       10 panel-NAMED-COLORS.
         15 panel-DEFAULT-COLOR         PIC XX VALUE LOW-VALUE.
         15 panel-WARNING-COLOR         PIC XX VALUE X'0301'.
         15 panel-HIGHLIGHT-COLOR       PIC XX VALUE X'0402'.
         15 panel-GAUDY-COLOR           PIC XX VALUE X'0503'.

So, if you want to change the color of a field named MYFIELD to GAUDY-COLOR, you just do this in your program:

     MOVE panel-GAUDY-COLOR TO MYFIELD-C.

The color value is persistent; it will remain set until you change it or clear it.  You can revert to the default color by moving panel-DEFAULT-COLOR to MYFIELD-C.

Related topics:


© 2000-2019 Norcom, all rights reserved 

TOC

Send feedback to Norcom