ApSetContext()

Set the PhAB context

Synopsis:

#include <Ap.h>

ApContext_t *ApSetContext( ApContext_t *context );

Arguments:

context
A pointer to the context you want to set the current PhAB context to. This argument should be the address of AbContext, a global data strcuture that PhAB puts into abmain.c, or NULL for no context.

Library:

Ap

Description:

ApSetContext() makes the given context current, and returns the previous current context. Both can be NULL; but if you pass a non-NULL pointer, it must point to a registered context.

At program startup, the program's PhAB context AbContext is made current. You can unset it or change it to a different context by calling ApSetContext(). You may want to do this in a DLL which calls Ap*() functions that use the current context.

In an application that doesn't involve DLLs, you can use this function to set the context to NULL when you're calling ApOpenDBaseFile(), to prevent the database from using your application's language translations if the file happens to contain widgets with the same name as one of your widgets.

Returns:

A pointer to the previous current context.

Examples:

This example sets the program's current context to NULL so that the widget database opened by ApOpenDBaseFile() doesn't use the current language translation:

 
ApContext_t *old = ApSetContext( NULL );
ApDBase_t *db = ApOpenDBaseFile( fname );
ApSetContext( old ); // Restore the program's context

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

Making a DLL out of a PhAB application in the Generating, Compiling, and Running Code chapter of the Photon Programmer's Guide