Getting a Pointer to the Current Item

Using the form pointer passed to the form, field, or event function, you can get the pointer to the current item.

To get the pointer to the current item on the form, call curitemp():

PTR curitemp(fmp)

FORMPTR fmp;               /* Pointer to the current form                */

Caution: You will have to cast the returned pointer to the appropriate type.

curitemp() returns a pointer to the current item, which may be a data field, menu field, memo, pushbutton, or scrollable region.

If you know that the current item is a field, and that it cannot be a scrollable region, you can use the more specific function, curfldp():

FIELDPTR curfldp(fmp)

FORMPTR fmp;              /* Pointer to the current form                     */

Alternatively, if you know that the current item is of a certain type, you can use the following functions, which do the casting for you. These functions are only valid in the appropriate context. For instance, if you are writing a begin-field or end-field function for a data field, you can call:

DFIELDPTR (dfmp)

DFORMPTR dfmp;          /* Pointer to the current form                    */

to get the pointer to the data field.

To get the pointer to the current memo field for the form, call:

MEMOPTR (dfmp)

DFORMPTR dfmp;          /* Pointer to the current form                    */

To get the pointer to the current menu field for a menu form, call:

MFIELDPTR curmfldp(mfmp)

MFORMPTR mfmp;          /* Pointer to the current menu form                */

To get the pointer to the current scrollable region for the form, call:

SRPTR (dfmp)

DFORMPTR dfmp;          /* Pointer to the current form                    */

This function returns a NULLP if the user is not in a scrollable region.


Home Contents Previous Next