Installing a Pointer to Data in the Window Structure

Read this section if you want to associate some kind of information, action, file, or data with a particular window.

One pointer within the window structure is reserved for your use. You can use this pointer to refer to information you want associated with a specific window. The user pointer can point to another structure, so there is no limit on the number of variables you can associate with a window structure.

To set the value of the user pointer, use the set user pointer function, userp_set():

void userp_set(p, wnp)
 
long p;
/* Generic pointer to data
*/
WINDOWPTR wnp;
/* Window to associate data with
*/

To retrieve the user pointer in the course of your program, use the get user pointer function, userp_get():

long userp_get(wnp)

WINDOWPTR wnp;        /* Window to retrieve user pointer from        */

You should take care that the variable pointed to by the user pointer exists (i.e., is in scope) at the time that the pointer is accessed. For instance, the variable should not be local to a function which will be terminated before the value is used.


Home Contents Previous Next