VERSIONS: All
SUBJECT: Property Color
BY: A. I. BREVELERI
Date: 2 July 2001
In Paradox for Windows, resolved colors are generally passed around as 32-bit values. The blue, green, and red intensities are encoded as
three 8-bit values which are then concatenated and written into the low 24 bits of the value. The remaining 8 bits are used to encode attributes of
the color, such as which palette map should be used to store it and so forth. The lowest of these 8 bits encodes a transparency attribute (often
mistakenly called translucency).
Numbering the bits in the standard way using hexadecimal notation, the highest order bit (which would be the sign bit in a signed integer) is
labeled 1F and the lowest order bit (which would have value = 1 in an integer) is labeled 00.
When encoding a color, bit 1F is unused and ignored (I think). Bits 1E..19 are used for attributes but I don't know what they are. Bit 18
specifies transparency. Bits 17..10 specify blue intensity. Bits 0F..08 specify green intensity. Bits 07..00 specify red intensity.
This diagram will show the bit positions if it isn't crumpled by your computer:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
F E D C B A 9 8 7 6 5 4 3 2 1 0 F E D C B A 9 8 7 6 5 4 3 2 1 0
: . . . . . . . : . . . . . . . : . . . . . . . : . . . . . . . :
| | | BLUE | GREEN | RED |
|
TRANSLUCENT ---'
One of the things that Windows will do for an application is draw a 'highlight' rectangle at a specified location. Windows creates the highlight
by complementing the blue, green, and red intensity values. BTW Windows draws the highlight after Paradox finishes rendering its screen, which
is why the highlight of an active field will bleed through any objects placed on top of it.
If you want to mimic the Windows highlight rectangle, you must complement the color values in the low 24 bits and leave the high 8 bits
alone. In assembly language, you would perhaps execute an XOR with the value 0x00FFFFFF, or possibly COM the number and then AND with
0x00FFFFFF. You can experiment with the bitwise operations of ObjectPAL. The decimal value of 0x00FFFFFF is 16777215. The value of the
transparency bit is hexadecimal 0x01000000 or decimal 16777216.
If you take the negative of a longint with a color in it, you don't get exactly the complementary color. You get a color close to the
complementary color with the transparency bit set. If the red value was zero, you get a color close to the complement of the blue and green, but
with red still zero (and transparency bit set).
I could do a section on binary arithmetic, but it all boils down to this: the best way to calc the complement of a 8-bit color value in ObjectPAL
is to subtract it from 255. That is:
InvRed = 255-FRed
Similarly, the best way to complement the colors in a color type is to subtract it from 16777215. That is:
InvColor = 16777215-FColor
This will complement the color values and leave the transparency bit alone.
From: Elmar von Muralt
Just one question though - as you said Windows does the handling of the colour complementing when a field gets focus. Does this mean I can't
disable the effect other than by setting a desired complements complement colour say on the arrive of a field?
Yes, that's exactly what it means. And it's almost impossible to get it to work without a lot of flickering and flashing of bizarre color
combinations. I think this is a good area to experiment in, not to get ultimate control over the highlight (which is probably impossible) but to gain
a deeper understanding of the timing of the Paradox event model interacting the Windows GDI.
SUBJECT: Windows Color
BY: PAUL CRONK
Date: 26 November 2002
Color, and colour constants have been around since Windows 3.1 And with every new version of windows, comes new colors, new formats,
and transitioning from the old to the new usually contains some areas of the operating system that falls between the cracks. Printing is a victim
and so are colors.
Microsoft came up with a bunch of color constants. In Windows 95, they added to these constants, but for some reason these new constants
had the same values as the old constants. Meaning, duplicate names. To further muddy the waters, some constants were only available on NT,
some on 95, and some on 98+. As we venture further in time, new constants are being created to support new operating systems.
You can primarily thank Borland for the list that we support. These constants were in version 7 as far as I know. There are 28/29 of them,
because they did a one-to-one mapping between constants and ObjectPAL constants, without taking into account that some of them are duplicates.
You can tell duplicate colour constants, because they have the same ObjectPAL constant value.
You can get the constant values by enumerating them to a table, and then viewing their value. Any duplicated constant values will have the
same or similar effect.
enumRTLConstants ("constants.db")
Note: A 3D element is an user-interface object that appears in 3D to the user. Such items might be buttons, radio buttons, checkboxes, but not
including basic windows. The display properties for the system is not sophisticated to set some of these colors.
Here is a complete list for those who don't want to waste anymore time.
Here is a complete list for those who don't want to waste anymore time.
| Tooltips | |
| clInfoBk | Background color for tooltip controls |
| clInfoText | Text color for tooltip controls |
| 3D Elements | |
| cl3dLight | light color for 3D elements |
| cl3dDkShadow | Dark shadow color for 3D elements |
cl3dHighlight,
cl3dHilight,
clBtnHighlight,
clBtnHilight | 3D element highlight color |
cl3dShadow,
clBtnShadow | 3D element shadow color |
| cl3dFace | 3D element face color |
| clBtnText | text on 3D elements. |
| clGrayText | disabled text color for 3D elements |
(eg, buttons have four sides, the highlight, the light, the shadow, and the dark shadow colors)
(eg, buttons have four sides, cl3dHighlight, cl3dLight, cl3dShadow, cl3dDkShadow) |
| System Colors | |
| clDesktop | background color of the desktop |
| Window constants | |
| clWindowFrame | window frame color |
| clWindow | background color of a window/control |
| clWindowText | window text color |
| clAppWorkspace | background color of MDI client window |
| Control specific colors | |
| clHighlightText | text color of items selected in a control |
| clHighlight | background color of items selected in a control |
| Window element constants | |
| clInactiveBorder | inactive border color |
| clActiveBorder | active border color |
| clMenu | color of the menu bar |
| clMenuText | menu text |
| clInactiveCaption | color of the inactive title bar |
| clCaptionText | color of the title bar |
| clInactiveCaptionText | color of the inactive title bar text |
I hope this clears things up a little.