Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/ap/apgetwidgetptr.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/ap/apgetwidgetptr.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/ap/apgetwidgetptr.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/ap/apgetwidgetptr.html on line 8

ApGetWidgetPtr()

Get the instance pointer for a widget in a given module

Synopsis:

#include <Ap.h>

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

Arguments:

link_instance
The link instance of the module that you want to search for the widget.
wgt_name
The ABN_ name of the widget that you want to find. PhAB automatically generates these name values for you when you generate your code.

Library:

Ap

Description:

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.


Note: You can also use AbGetABW() to get the widget instance pointer more efficiently, though AbGetABW() does not work when there are multiple instances of the widget's window module.

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.

Returns:

A pointer to the widget within the module link_instance, or NULL if it wasn't found.

Examples:

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 );
        PtSetResources(
            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.

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

AbGetABW(), ApGetInstance()

Handling multiple instances of a window in the Working with Code chapter of the Photon Programmer's Guide


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/ap/apgetwidgetptr.html on line 176

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/ap/apgetwidgetptr.html on line 176