Specifying a Message for an Active Field

You can specify a message that you want to appear in the message window for a field. This field message is useful for giving the user more information about what to enter in the field, how to get help, and whether a choice list is available for the field. When you specify a field message, the information is stored in the data field structure.

When the user goes to the field, the message window is displayed, if it is not already, and the field message is written in the message window. The message remains in the message window until the user leaves the field, or until another function writes to the message window. The message window is, by default, a borderless window that covers the last line of the screen and uses the logical attribute LMESSAGE. These defaults can be changed (see Chapter 15, "Changing the Appearance of Data Forms").

Field messages are separate from the help facility. You can also assign field-specific help information that is shown when the user presses the Help key (KEY_F1, by default). The help system is described in Chapter 44, "The Help System."

Designer: You can specify the field message in the "Basic Field Information" dialog box in the Designer. See the Designer User's Guide for details. You can also add field messages in code, at any point after you have read the form from the Designer library.

Code: You can specify the field message at any point after defining the field with fld_def().

General: To specify the field message in code, use the set field message function, sf_msg() function:

void sf_msg(msg_stp, fldp)

UCHAR *msg_stp;        /* Message to appear in window            */

FIELDPTR fldp;        /* Pointer to field to install message        */

Code: For example, the following code fragment defines a field to enter a currency amount (with right entry) and specifies the message to appear in the message window. When this field becomes active, this message is displayed in the message window to guide the user.

FIELDPTR dfldp;

long price = 0L;

...

...

dfldp = fld_def(1, 5, "Price: ", FADJACENT, "9999.99", 

              F_DECIMAL, (PTR) &price, dfmp);

sf_opt(RTENTRY, ON, dfldp);

sf_msg("Press <F1> for a current price list.",  dfldp);


Home Contents Previous Next