Modifying the Window for a Particular Menu

Designer: Many aspects of the form window can be modified in the Designer. See the Designer User's Guide for more information. You can also call the window functions from your code, at any point after reading the form from the Designer library.

Code: To modify the window that displays a menu, you use the many window functions available. Window functions generally take a window pointer as an argument. The pointer to the menu window is contained in the menu form structure. To access this window, use:

mfmp->wnp

For example, the following code adds a title to the window border. The text is "Top Menu." It will be entered in the top of the border of the menu window and displayed with the LHIGHLITE logical attribute:

MFORMPTR mfmp;

mfmp = mn_def(MNSTANDARD, 0, 0, 10, 40, LMNINACT, BDR_SLNP);

sw_title("Top Menu", LHIGHLITE, TOPCENTER, mfmp->wnp);

The next time the menu is displayed, this title will appear in the border of the menu window.

You may also want to change the logical attribute array used by the menu. The window structure has as one of its members a pointer to a logical attribute array. If this member is specified, the window uses the definitions in this logical attribute array. Otherwise, either the system logical attribute array or the Designer library logical attribute array is used, depending on whether the menu was created in code or in the Designer.

To specify the logical attribute array to be used for a menu form, simply change the attribute array associated with the menu form window using the set window logical attribute array function, sw_latt():

sw_latt(latt_array, wnp)
 
UCHAR latt_array[];
/* Logical attribute array
*/
WINDOWPTR wnp;
/* Pointer to window
*/

For example:

UCHAR my_latt[25];

sw_latt(my_latt, mfmp->wnp);

The system logical attribute array is #defined as LATT_SYS. If you want to reinstall the system logical attribute array for a form, specify LATT_SYS for the attribute array.

For complete information about these and other functions that control the appearance of windows, see Chapter 25, "Changing the Appearance of Windows." For complete information about using logical attributes, see Chapter 46, "Controlling Color with Logical Attributes."

Caution: If you are changing the size of a menu window and the menu fields have already been defined for the menu, make sure the new menu window is large enough to hold the defined menu fields.

Note: It is generally not a good idea to access structure members directly, since structure member names may change in future releases. However, there are a few names which we are not likely to change. One of these is mfmp->wnp.


Home Contents Previous Next