Jump to content

WinSetSysColors

From EDM2
Revision as of 04:27, 29 February 2020 by Martini (talk | contribs) (Created page with "This function sets system color values. ==Syntax== WinSetSysColors(hwndDeskTop, flOptions, ulFormat, lStart, ulTablen, alTable); ==Parameters== ;hwndDeskTop (HWND) - inpu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function sets system color values.

Syntax

 WinSetSysColors(hwndDeskTop, flOptions, ulFormat, lStart, ulTablen, alTable);

Parameters

hwndDeskTop (HWND) - input
Desktop-window handle.
HWND_DESKTOP
The desktop-window handle
Other
Specified desktop-window handle.
flOptions (ULONG) - input
Options.
LCOL_RESET
The system colors are all to be reset to default before processing the remainder of the data in this function.
LCOL_PURECOLOR
Color-dithering should not be used to create colors not available in the physical palette. If this option is set, only pure colors are used and no dithering is done.
ulFormat (ULONG) - input
Format of entries in the table, as follows.
LCOLF_INDRGB
Array of (index,RGB) values. Each pair of entries is 8-bytes long, comprising 4 bytes for the index, and 4 bytes for the color value. For system color indexes, see lStart.
LCOLF_CONSECRGB
Array of (RGB) values, corresponding to color indexes lStart upwards. Each entry is 4-bytes long.
lStart (LONG) - input
Starting system color index.
This parameter is applicable only if the ulFormat parameter is set to LCOLF_CONSECRGB.
The number of system colors (as defined below) is given by SYSCLR_CSYSCOLORS.
The following system color indexes are defined (each successive index is one larger than its predecessor):
SYSCLR_ENTRYFIELD
Entry field and list box background color.
SYSCLR_MENUDISABLEDTEXT
Entry field background color.
SYSCLR_MENUHILITE
Selected menu item text.
SYSCLR_MENUHILITEBGND
Selected menu item background.
SYSCLR_PAGEBACKGROUND
Notebook page background.
SYSCLR_FIELDBACKGROUND
Inactive scroll bar and default control background color.
SYSCLR_BUTTONLIGHT
Light push button (3D effect).
SYSCLR_BUTTONMIDDLE
Middle push button (3D effect).
SYSCLR_BUTTONDARK
Dark push button (3D effect).
SYSCLR_BUTTONDEFAULT
Push button.
SYSCLR_TITLEBOTTOM
Line drawn under title bar.
SYSCLR_SHADOW
Drop shadow for menus and dialogs.
SYSCLR_ICONTEXT
Text written under icons on the desktop.
SYSCLR_DIALOGBACKGROUND
Pop up dialog box background.
SYSCLR_HILITEFOREGROUND
Selection foreground.
SYSCLR_HILITEBACKGROUND
Selection background.
SYSCLR_INACTIVETITLETEXTBKGD
Background of inactive title text.
SYSCLR_ACTIVETITLETEXTBKGD
Background of active title text.
SYSCLR_INACTIVETITLETEXT
Inactive title text.
SYSCLR_ACTIVETITLETEXT
Active title text.
SYSCLR_OUTPUTTEXT
Output text.
SYSCLR_WINDOWSTATICTEXT
Static (nonselectable) text.
SYSCLR_SCROLLBAR
Active scroll bar background area.
SYSCLR_BACKGROUND
Desktop background.
SYSCLR_ACTIVETITLE
Active window title.
SYSCLR_INACTIVETITLE
Inactive window title.
SYSCLR_MENU
Menu background.
SYSCLR_WINDOW
Window background.
SYSCLR_WINDOWFRAME
Window frame (border line).
SYSCLR_MENUTEXT
Normal menu item text.
SYSCLR_WINDOWTEXT
Window text.
SYSCLR_TITLETEXT
Text in title bar, size box, scroll bar arrow box.
SYSCLR_ACTIVEBORDER
Border fill of active window.
SYSCLR_INACTIVEBORDER
Border fill of inactive window.
SYSCLR_APPWORKSPACE
Background of specific main windows.
SYSCLR_HELPBACKGROUND
Background of help panels.
SYSCLR_HELPTEXT
Help text.
SYSCLR_HELPHILITE
Highlighted help text.
SYSCLR_SHADOWHILITEBGND
Shadows of workplace object background highlight color.
SYSCLR_SHADOWHILITEFGND
Shadows of workplace object foreground highlight color.
SYSCLR_SHADOWTEXT
Shadows of workplace object text color.
ulTablen (ULONG) - input
Number of elements.
Number of elements supplied in alTable. This may be 0 if, for example, the color table is merely to be reset to the default. For LCOLF_INDRGB it must be an even number.
alTable (PLONG) - input
Table.
Start address of the application data area, containing the color-table definition data. The format depends on the value of ulFormat.
Each color value is a 4-byte integer, with a value of
R * 65536) + (G * 256) + B
where:
R is red intensity value
G is green intensity value
B is blue intensity value.
There are 8 bits for each primary; the maximum intensity for each primary is 255.

Return Code

rc (BOOL) - returns
Success indicator.
TRUE
Successful completion
FALSE
Error occurred.

Possible returns from WinGetLastError

PMERR_INVALID_HWND (0x1001)
An invalid window handle was specified.
PMERR_INVALID_FLAG (0x1019)
An invalid bit was set for a parameter. Use constants defined by PM for options, and do not set any reserved bits.
PMERR_PARAMETER_OUT_OF_RANGE (0x1003)
The value of a parameter was not within the defined valid range for that parameter.


Calling Sequence

#define INCL_WINSYS /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

HWND     hwndDeskTop;  /*  Desktop-window handle. */
ULONG    flOptions;    /*  Options. */
ULONG    ulFormat;     /*  Format of entries in the table, as follows. */
LONG     lStart;       /*  Starting system color index. */
ULONG    ulTablen;     /*  Number of elements. */
PLONG    alTable;      /*  Table. */
BOOL     rc;           /*  Success indicator. */

rc = WinSetSysColors(hwndDeskTop, flOptions,
       ulFormat, lStart, ulTablen, alTable);

Sample

This example changes the desktop background to blue and the output text to green.


#define INCL_WINSYS
#define INCL_GPILOGCOLORTABLE
#include <OS2.H>

typedef struct {
LONG index;
LONG color;
               } ENTRY;
LONG R, G ,B;

ENTRY alTable[2];  /* array of two color/index entries. */

R = 5L; G = 5L; B = 200L;
alTable[0].color = (R * 65536L) + (G * 256L) + B;
R = 5; G = 200; B = 5;
alTable[1].color = (R * 65536L) + (G * 256L) + B;
alTable[0].index = SYSCLR_OUTPUTTEXT; /* output text. */
alTable[1].index = SYSCLR_BACKGROUND; /* desktop background. */

WinSetSysColors (HWND_DESKTOP,
                LCOL_RESET,     /* reset system colors before   */
                                   /* processing remainder of this */
                                   /* call.                        */
                LCOLF_INDRGB,   /* Array of (index,RGB) */
                                   /* values. Each pair of */
                                   /* entries is 8 bytes   */
                                   /* long, comprising 4   */
                                   /* bytes for the index, */
                                   /* and 4 bytes for the  */
                                   /* color value. For     */
                                   /* system color indexes,*/
                                   /* see lStart.          */
                0L,                /* not applicable.      */
               (ULONG)4,
               (PLONG)&alTable[0].index);



Remarks

This function sends all main windows in the system a WM_SYSCOLORCHANGE message to indicate that the colors have changed. When this message is received, applications that depend on the system colors can query the new color values with the WinQuerySysColor function.

After the WM_SYSCOLORCHANGE messages are sent, all windows in the system are invalidated so that they are redrawn with the new system colors.

This function does not write any system color changes to the initialization file See

The following table gives the default RGB values for each color index:

┌────────────────────────────┬───────────┬───────────┐
│System Color Index          │Default    │Default RGB│
│                            │Color      │Values     │
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_ACTIVEBORDER         │Pale yellow│255 255 128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_ACTIVETITLE          │Teal       │64  128 128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_ACTIVETITLETEXT      │White      │255 255 255│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_ACTIVETITLETEXTBGND  │Teal       │64  128 128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_APPWORKSPACE         │Off-white  │255 255 224│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_BACKGROUND           │Light gray │204 204 204│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_BUTTONDARK           │Dark gray  │128 128 128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_BUTTONDEFAULT        │Black      │0   0   0  │
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_BUTTONLIGHT          │White      │255 255 255│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_BUTTONMIDDLE         │Light gray │204 204 204│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_DIALOGBACKGROUND     │Light gray │204 204 204│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_ENTRYFIELD           │Pale yellow│255 255 204│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_FIELDBACKGROUND      │Light gray │204 204 204│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_HELPBACKGROUND       │White      │255 255 255│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_HELPHILITE           │Blue green │0   128 128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_HELPTEXT             │Dark blue  │0   0   128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_HILITEBACKGROUND     │Dark gray  │128 128 128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_HILITEFOREGROUND     │White      │255 255 255│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_ICONTEXT             │Black      │0   0   0  │
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_INACTIVEBORDER       │Light gray │204 204 204│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_INACTIVETITLE        │Light gray │204 204 204│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_INACTIVETITLETEXT    │Dark gray  │128 128 128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_INACTIVETITLETEXTBGND│Light gray │204 204 204│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_MENU                 │Light gray │204 204 204│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_MENUDISABLEDTEXT     │Dark gray  │128 128 128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_MENUHILITE           │Black      │0   0   0  │
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_MENUHILITEBGND       │Light grey │204 204 204│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_MENUTEXT             │Black      │0   0   0  │
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_OUTPUTTEXT           │Black      │0   0   0  │
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_PAGEBACKGROUND       │White      │255 255 255│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_SCROLLBAR            │Pale gray  │192 192 192│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_SHADOW               │Dark gray  │128 128 128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_SHADOWHILITEBGND     │Dark gray  │128 128 128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_SHADOWHILITEFGND     │White      │255 255 255│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_SHADOWTEXT           │Dark gray  │128 128 128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_TITLEBOTTOM          │Dark gray  │128 128 128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_TITLETEXT            │White      │255 255 255│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_WINDOW               │White      │255 255 255│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_WINDOWFRAME          │Dark gray  │128 128 128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_WINDOWSTATICTEXT     │Blue       │0   0   128│
├────────────────────────────┼───────────┼───────────┤
│SYSCLR_WINDOWTEXT           │Black      │0   0   0  │
└────────────────────────────┴───────────┴───────────┘

Related Functions

  • WinQuerySysColor
  • WinSetSysColors

Related Messages

  • WM_SYSCOLORCHANGE