Purpose |
Set the background color of a dialog to a specific RGB color. |
Syntax |
DIALOG SET COLOR hDlg, foreclr&, backclr& |
Remarks |
hDlg identifies the dialog to colorize. Color values foreclr& and backclr& must be in the range of &H0 to &H00FFFFFF, while the value -1& is used to specify the system default color. RGB can be a useful function to derive a 32-bit color value from discrete Red, Green and Blue values. |
foreclr& |
In the current implementation of PowerBASIC, the dialog foreground color parameter foreclr& is not used, but the syntax is retained for future implementation. It is recommended that the foreground color parameter be set to -1&. |
backclr& |
In 16-bit or greater color-depth mode, the RGB color specified is used when the background of the dialog is drawn. If backclr& = -1&, the default dialog background color is used. If backclr& = -2&, the dialog background is not painted, allowing the content behind the dialog to become visible through the dialog. In 16-bit or greater color-depth mode, the specified RGB color is used when the background of the dialog is drawn. However, in 8-bit (256-color) mode, the color system works quite differently. Behind the scenes in Windows, the base system palette usually contains 20 solid colors that are not dithered when drawn on a dialog background. These solid-colors are ideal for background colors with DDT dialogs in 256-color mode. Conversely, when using a non-solid RGB color value, Windows will dither (approximate) the color to draw the dialog, using combinations of two or more colors. This usually produces an undesirable pattern effect. To avoid these problems when in 256-color mode, dialogs should either be colored with one of the 20 standard (solid) system colors, or the default color should be used instead. PowerBASIC includes the following 10 built-in equates for help with the selection of a standard solid color: %RGB_BLACK %RGB_BLUE %RGB_GREEN %RGB_CYAN %RGB_RED %RGB_MAGENTA %RGB_YELLOW %RGB_WHITE %RGB_GRAY %RGB_LIGHTGRAY Many non standard colors are also built into the compiler, see the Built In RGB Color Equates topic for a complete list. If you prefer to disable color in 256-color mode, the number of colors can be easily tested with the following code: ' Determine number of colors In 256-color mode on most computers, the values of the standard 20 system colors can be found by requesting the first and last 10 (0 to 9, and 246 to 255 inclusive) entries from the GetSystemPaletteEntries API function, as follows: ' Fill array with solid colors For more information on working with palettes in 256-color mode, please consult WIN32.HLP or visit http://msdn.microsoft.com. When dynamically changing colors of a dialog from within a callback
(i.e., after the
Without a forced dialog redraw, the dialog background color change may not become evident to the user until the dialog is eventually repainted in the normal course of user interaction. For example, a normal repaint may only occur if the dialog becomes obscured and then uncovered by another window. Ensuring a timely repaint of the dialog will guarantee the dialog maintains an up-to-date appearance at all times. |
See also |
Built In RGB Color Equates, Dynamic Dialog Tools, CONTROL REDRAW, DIALOG REDRAW, CONTROL SET COLOR, DIALOG SET ICON |
Example |
DIALOG NEW 0, "Dialog",,, 160, 120,
TO hDlg |