v1.10 |
509 Center Bay City, Michigan Sales (989) 892-9242             Support (989) 686-8860 |
- Topics
- See also
INTRODUCTION
Gotta flesh this topic out at some time! In the meantime:
The basic instructions are:MY_COLOR COLOR YOUR_COLOR COLOR WORK_COLOR COLOR CREATE MY_COLOR={*colordef} ;basic colors are in language CREATE MY_COLOR={red}:{green}:{blue} ;use decimal numbers CREATE MY_COLOR={another color object} CREATE MY_COLOR=*BLUE CREATE MY_COLOR=255:244:197 CREATE YOUR_COLOR=MY_COLOR GETPROP Any_EditText, BGCOLOR=WORK_COLOR ;transfer color SETPROP Another_EditText, BGCOLOR=WORK_COLOR ;from one obj to another . To set list view row colors you need to use the hex value string . which can be a string variable or a literal: HEX_COLOR DIM 8 PACK HEX_COLOR, "0x", HEX_RED, HEX_GREEN, HEX_BLUE ListView001.SetItemText USING {row index}, HEX_COLOR, {color column} ---- or as a literal ---- ListView001.SetItemText USING {row index}, "0xCFA5F1", {color column}If you have HEX RGB color codes (FFC4F5) you need to split that and convert it to decimal before use. MMCC has a hex conversion routine in the MMCCSERV include routine:CALL HEX_TO_DECIMAL USING "F5", DECIMAL_RETURN .... inverse: CALL DECIMAL_TO_HEX USING "254",HEX_RETURNMMCC Staff: See ZZCOLORS test program in UTIL-PLB.
See COLORGET.PLS in SUNDB and FR-88020 in Freddy Mobile.
Freddy Mobile allows users to select colors for various displays. The user clicks a button and is presented with the standard color selection box. The image at right shows part of that screen. The edit text to the right is the current color.
To get the color selection panel, you create a color object without any parameters. Once the color is defined you can get the properties from that color object to see what was chosen.
If the user CANCEL's the color box, the object is not created. You have to trap an object error to detect that condition.
The example code below can be used to get a color as done in FM-88020. This uses the GET_COLOR_DEF routine found in the standard MMCC COLORGET.PLS include routine found in SUNDB. That routine will get the color properties from any object and format it in a variety of ways that can be used for other things.
If the color is to be saved as a configuration setting, the HEX or DECIMAL values are useful. Setting ListView colors, for example, requires that you use the HEX values. Other color objects can be set with the decicmal values.
We use the routine below to get the user's color selection. The decimal and hex color codes are saved in the XC file and can be used as needed. Decimal values are used for creating colors, the HEX values are used for list views.
................................... . Sample of getting a color to be stored . as done in FM-88020 . CUSTOM_COLOR COLOR . COLOR_RED FORM 3 COLOR_GREEN FORM 3 COLOR_BLUE FORM 3 . HEX_RED DIM 2 HEX_GREEN DIM 2 HEX_BLUE DIM 2 . COLOR_24BITS FORM 12 COLOR_TYPE DIM 1 INTEGER_4 INTEGER 4 . get_color_value MOVE NO, OBJNIF TRAP OBJECT_ERROR IF OBJECT CREATE CUSTOM_COLOR TRAPCLR OBJECT IF (OBJNIF != NO) RETURN ENDIF . CALL GET_COLOR_DEF USING CUSTOM_COLOR: COLOR_RED, COLOR_GREEN, COLOR_BLUE: HEX_RED, HEX_GREEN, HEX_BLUE: COLOR_24BITS: COLOR_TYPE: INTEGER_4 IF (COLOR_TYPE = "W") SETPROP EditText_Sample, BTCOLOR=INTEGER_4 DISPLAY "Windows index color:",COLOR_24BITS ELSE SETPROP EditText_Sample, BGCOLOR=CUSTOM_COL DISPLAY "Hex:",HEX_RED,":",HEX_GREEN,":",HEX_BLUE ENDIF . . save the COLOR_xxx and the HEX_xxx values in the . programs options in the XC file. . RETURN . INCLUDE Z:COLORGET ;get_color_def
Here's another way to use the designer to get colors.
ListView colors must be coded as a hex string in the form "0xF17CF0". There's no direct way to get this string other than defining it as a literal or using a technique like the one described in the section above. It would be nice to just get a color at run-time from an object on screen and ust that. Unfortunately you can't use the color directly. It would be nice to just GETPROP BGCOLOR and use that color. Sorry... Won't work.
But you can get an object's color components at run-time and use them to build that hex string. The technique is to:
Get the color components for the object in question as decimal numbers.
Convert each decimal number to a hex.
Build a STRING that the ListView will accept.
Here's our routine, which uses MMCC's standard DECIMAL_TO_HEX utility routine:
MAKE A HEX STRING FROM AN OBJECTS COLORS:
WORK_COLOR COLOR ;color object WORK_RED FORM 3 WORK_GREEN FORM 3 WORK_BLUE FORM 3 HEX_COLOR DIM 8 HEX_RETURN DIM 2 GETPROP ET_Sample, BGCOLOR=WORK_COLOR ;Get color from form. GETPROP WORK_COLOR, 1, WORK_RED ;Split out the components GETPROP WORK_COLOR, 2, WORK_GREEN GETPROP WORK_COLOR, 3, COLOR_BLUE PACK HEX_COLOR, "0x" ;Initialize color string CALL DECIMAL_TO_HEX, WORK_RED, HEX_RETURN PACK HEX_COLOR, HEX_COLOR, HEX_RETURN CALL DECIMAL_TO_HEX, WORK_GREEN, HEX_RETURN PACK HEX_COLOR, HEX_COLOR, HEX_RETURN CALL DECIMAL_TO_HEX, WORK_BLUE, HEX_RETURN PACK HEX_COLOR, HEX_COLOR, HEX_RETURNThe result is that HEX_COLOR comes out something like "0xF175C1"
The idea for this ccame from a Sunbelt Forum posting from John Shrimski 2/6/2004. John's original posting was:
Ive been playing around with color objects recently (using plbwin 8.6c), and I think I've found an error with the blue component when setting an RGB color ...... for examplergb integer 4 red form 3 green form 3 blue form 3 c color create c=*white getitem c,1,red (red=255) getitem c,2,green (green = 255) getitem c,3,blue (blue = 255) getitem c,0,rgb (rgb = 0xFFFFFF00) .... all the above works fine SETitem c,0,rgb getitem c,1,red (red = 255) getitem c,2,green (green = 255) getitem c,3,blue (blue = 0 ) getitem c,0,rgb (rgb = 0xFFFF0000)i.e., the blue component has been lost. The work around is to always use a CREATE on a color object Is this a bug, or have I missed something?
John Shrimski,
CONTENTS
v1.10 Send e-mail to MMCC.
Write to MMCC Technical Support at:MMCC, Inc.
600 W. Midland
Bay City, MI 48708
(989) 686-8860| Home   |
© 1997 - 2003 MMCC, Inc. All Rights Reserved.
Report problems or suggestions to support@mmcctech.com