Problem:
The Dialog System "Color Selection" dialog box for setting colors of controls has a very limited selection of colors to choose from. To get a more varied selection of color choices, you can use the Micro Focus GUI Class Library. This means that you will have to add extra Dialog code for each control that you want to color by way of the class library.
Resolution:
INTRODUCTION
==========
The Dialog System "Color Selection" dialog box for setting colors of controls has a very limited selection of colors to choose from. To get a more varied selection of color choices, you will have to make use of the Micro Focus GUI Class Library. This means that you will have to add extra Dialog code for each control that you want to color by way of the class library.
To enable use of the class library from within Dialog System, add the following code to the
SCREENSET-INITIALIZED event in Screenset...Global Dialog:
CLEAR-CALLOUT-PARAMETERS $NULL
CALLOUT-PARAMETER 1 CONFIG-FLAG $NULL
CALLOUT-PARAMETER 2 CONFIG-VALUE $NULL
MOVE 15 CONFIG-FLAG
MOVE 1 CONFIG-VALUE
CALLOUT "dsrtcfg" 3 $PARMLIST
and datablock definitions:
CONFIG-FLAG C5 4.0
CONFIG-VALUE C5 4.0
For each control that you want to color (an entry field, for instance), you will need to get an object handle by using the MOVE-OBJECT-HANDLE Dialog function. You then use the INVOKE Dialog function to invoke the "fromHandle" method of the window class (in the GUI Class Library) to get an object reference that represents the object handle. You can see this code in the demo by right-clicking the window, selecting "Dialog..." from the pop-up menu and looking at the code in the WINDOW-CREATED event:
MOVE-OBJECT-HANDLE EF-COLOR EF-HANDLE
CLEAR-CALLOUT-PARAMETERS $NULL
CALLOUT-PARAMETER 1 EF-HANDLE $NULL
CALLOUT-PARAMETER 8 EF-OBJECT $NULL
INVOKE "window" "fromHandle" $PARMLIST
Please see the Dialog System Help for a description of the INVOKE function and it's parameters. Parameter 1, in this case, is the control's handle and parameter 8 is the object reference that is returned. This object reference is what is used as a parameter for the INVOKE function when setting the color.
I have added a SET-THE-COLOR procedure in the window dialog that does the work of setting the background color of the entry field in the demo. This procedure is executed when you press the "Set Color" button. You can use the "setBackgroundRGB" method on the object reference that represents the object handle of the control (entry field) that you want to color. The "setBackgroundRGB" method belongs to the AbstractWindow class (the super class of the window class) in the GUI Class Library. See the NetExpress\\base\\bin\\ MFNXCL31.CHM file in NetExpress 3.1 or the Contents...Reference...OO COBOL...GUI Class Library topic in the NetExpress 4.0 help. This method takes 3 parametes, a Red value, a Green value, and a Blue value specified in the PARMLIST:
MOVE RED-VALUE RED
MOVE GREEN-VALUE GREEN
MOVE BLUE-VALUE BLUE
CLEAR-CALLOUT-PARAMETERS $NULL
CALLOUT-PARAMETER 1 RED $NULL
CALLOUT-PARAMETER 2 GREEN $NULL
CALLOUT-PARAMETER 3 BLUE $NULL
INVOKE EF-OBJECT "setBackgroundRGB" $PARMLIST
You can also set the foreground color using the "setForegroundRGB" method. Instead of using a button to execute the procedure that sets the color, you can specify all of the code in the WINDOW-CREATED event of your window, or anywhere else that it's required. More information about RGB (Red, Green, Blue) settings can be found by doing a search of "color rgb" on the internet. Often times, these color settings are specified in hexadecimal, but can be converted to decimal.
It is a good idea to clean up objects that you have created when you are done using them. In this simple demo, it is not necessary, but if you create a lot of object references, you should add code similar to this when you are done using an object (EF-OBJECT in this case):
CLEAR-CALLOUT-PARAMETERS $NULL
CALLOUT-PARAMETER 8 EF-OBJECT $NULL
INVOKE EF-OBJECT "finalize" $PARMLIST
SOURCE FILES:
==========
Program Files Description
---------------- -----------------------------------------------------------
dscolor.app Net Express project
dscolor.cbl Main Cobol source code
dscolor.cpb Dialog System datablock copyfile
dscolor.gs Dialog System screenset
dserror.err Dialog System error messages file (for validation)
OPERATION:
========
Build and run the project. You can play around with setting the Red, Green, and Blue values to get the color you want. Click on the "Set Color" button to set the background color of the entry field.
==========================================================
Keywords: demonstration, sample, example, demo, Dialog System, DSColor.zip
demo.ex
demo.ne