Consultor Eletrônico



Kbase P16365: How to change colors dynamically
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   30/03/2010
Status: Verified

GOAL:

How to change colors dynamically in character session

GOAL:

How to change colors in CHUI session dynamically

GOAL:

How to define colors for a character (CHUI) client

FACT(s) (Environment):

OpenEdge Category: Language (4GL/ABL)
Progress 9.x
OpenEdge 10.x
Windows

FIX:

Windows Character client colours can be specified in the following section of the registry:

HKEY_CURRENT_USER/software/psc/9.1X/WinChar Colors


or in a progress ini file under the "WinChar Color" section: colors.ini

[WinChar Colors]
color0= LIGHT-CYAN/BLUE "NORMAL"
color1=BLACK/GRAY "INPUT, UNDERLINE"
color2=YELLOW/BLUE "MESSAGES, REVERSE"
color3=BLUE/WHITE "HIGHLITE, HELP"
color4=BLINK-RED/WHITE "URGENT"
?
color255=YELLOW/RED "budgie"

The following example deals with using a progress.ini file:

For CHUI, the colours are loaded at startup. Any loading of an_other.ini during runtime, (LOAD, USE) will only take effect in the next window. Since CHUI does not do ?multiple windows? a workaround could be to close the first and start a second, but that would be clumsy.

TO demonstrate colours: (using above definition)

/* GKV.p | START */

define var a as char.
get-key-value section "WinChar colors" key "color0" value a.
Message a view-as alert box.

/* GKV.p | END */

If the CHUI client is started as:
%DLC%\_progress.exe
>> running GKV.p will return the default for color0: WHITE/BLUE

BUT, If the CHUI client is started as:
%DLC%\_progress.exe -basekey INI -ininame colors.ini
>> then running GKV.p will return the defined color0: LIGHT-CYAN/BLUE

So, how can colours be dynamically changed in a character session?
In GUI, a 'layer' was introduced so that colours/fonts/variables can be changed on the fly - for the subsequent windows that the application creates. But CHUI doesn't 'do' multiple windows and this layer has not been implemented for CHUI.

IF 255 colours would be sufficient, the following demonstrates changing the colours of a frame, for example. Please note that the colours need to be defined sequentially. In other words, no skipping numbers..

/* Assuming that 255 colors is enough
%DLC%\_progress.exe -basekey INI -ininame colors.ini
*/

DEFINE VAR a AS CHAR INITIAL "COLORS".
DEFINE FRAME f a.
DISPLAY A WITH FRAME f.
PAUSE 2.
FRAME f:DCOLOR = 255. /* for the WHOLE frame */
/* or this for the text in frame */
/* a:DCOLOR IN FRAME f = 255 */
PAUSE.
/* ------------------end ---------------------------*/

The
"a:DCOLOR IN FRAME f = 255"
for example, could have the 'f =' as a variable i as int, which the user session could pass
or as database.table. The colours are separated with a '/' so two fields could be defined in the table.