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/apgetinstance.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/apgetinstance.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/apgetinstance.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/apgetinstance.html on line 8

ApGetInstance()

Get the module link instance pointer for a widget

Synopsis:

#include <Ap.h>

PtWidget_t *ApGetInstance( PtWidget_t *widget );

Arguments:

widget
A pointer to the widget that you want to get the module link instance pointer for.

Library:

Ap

Description:

ApGetInstance() is used to obtain the widget's module link instance pointer. For most modules, PhAB generates manifests that let you access the widgets within that 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 module link_instance pointer when creating the window, or to use this function within the callback to determine the origin of the callback.

Returns:

The module link instance pointer for the widget, or NULL if it can't be determined.

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,
                        ApName( widget ) ), 1, args );
    }

    return( Pt_CONTINUE );
}

Note: An interesting observation about this callback example is that it doesn't know which window is being modified or which widget gets changed. It acts on whatever widget the user selects.

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

ApGetWidgetPtr()

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/apgetinstance.html on line 154

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/apgetinstance.html on line 154