[Previous] [Contents] [Index] [Next]


Get the instance pointer for a widget in a given module


#include <Ap.h>

PtWidget_t *ApGetWidgetPtr( PtWidget_t *link_instance,
                            int wgt_name );


ApGetWidgetPtr() is used to obtain the widget's instance pointer within the specified link_instance. For most modules, PhAB generates manifests that let you access the widgets within the module directly, provided only one instance of the module exists at a time.

Because window modules allow you to have multiple instances you can't always use the direct access manifests; the manifest will only be valid for the last instance of the window. For windows, you may need either to save the link_instance pointer when creating the window, or to use this function to find the correct link_instance for the callback.

Once you determine the module link instance, you'll need to extract the widget pointer from it.

The wgt_name argument is the ABN_ name value of the widget. PhAB automatically generates these name values for you when you generate your code.


A pointer to the the widget within the module link_instance, or NULL if one was not found.


PtArg_t        args[1];

mywindow_callback( PtWidget_t *widget, ... )
    PtWidget_t   *window;

    /* from which window did this come? */
    if ( window = ApGetInstance( widget ) ) {
        /* set the widget selected to red */
        PtSetArg( &args[0], Pt_ARG_FILL_COLOR, 
                  Pg_RED, 0 );
            ApGetWidgetPtr( window, ABN_mywidget ),
            1, args );

    return( Pt_CONTINUE );

Note: If you compare this example with the one for ApGetInstance(), you'll notice a subtle difference. This example modifies a specific widget identified by ABN_mywidget, while the other example modifies any widget affected by the callback.



Interrupt handler No
Signal handler No
Thread No

See also:


[Previous] [Contents] [Index] [Next]