Changing a Logical Attribute Definition at Run-Time

Logical attributes are generally defined in the header files, and their definitions remain the same during the course of a program. You may want the user to be able to set the color combinations to be used during the course of the program, or you may not want to make your changes in the header file. You can change an existing logical attribute definition at run-time with the logical attribute replace function, latt_rpl():

void latt_rpl(log_att, mono_att, fg_att, bg_att, latt_array)
 
UCHAR log_att;
/* Logical attribute to change
*/
UCHAR mono_att;
/* Monochrome physical attribute
*/
UCHAR fg_att;
/* Color physical attribute for foreground
*/
UCHAR bg_att;
/* Color physical attribute for background
*/
UCHAR *latt_array;
/* Logical attribute array to change
*/

The system logical attribute array is #defined as LATT_SYS, for your convenience.

As an example, suppose you want to change the colors associated with the logical attribute LHELP, which is initially defined as high intensity normal for monochrome modes and blue on white for color modes.

latt_rpl(LHELP, NORMAL, LIGHT | BLUE, BLUE, LATT_SYS);

The function checks what the current video mode is. If it is monochrome, NORMAL is copied into the system logical attribute array. If it is color, the physical attribute byte is determined and copied into the array. Note that this function does not permanently change the system logical attribute table.

The function latt_rpl() works only for existing logical attributes in the array, even if that logical attribute currently has no attributes associated with it. You cannot add a logical attribute to the array with this function.

Getting a Pointer to the Logical Attribute Array Used by a Designer Library

In order to replace a logical attribute in the table used by a Designer library, you must get a pointer to the table. To do this, use the Designer library logical attributes pointer function dl_lattp():

UCHAR *dl_lattp(libname_stp)

UCHAR *libname_stp;      /* Name of library             */

This function returns a pointer to the logical attribute table used by that library. You can then call latt_rpl() using that pointer.


Home Contents Previous Next