Condividi tramite


_ActivateIdle( ) API Library Routine

Adds an idle handler function to the end of the list of idle event handlers called when Visual FoxPro is waiting for user input or for an event to time out.

unsigned int _ActivateIdle(FPFI handler) 
FPFI handler               /* Event handler. */

Remarks

_ActivateIdle( ) returns an integer identifier for this routine. Use the identifier to remove the idle event handler from the idle loop with _DeActivateIdle( ).

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.

Example

The following example activates an idle event handler when the library is loaded. The idle event handler just prints a message. The idle event handler is deactivated when the library is unloaded.

Visual FoxPro Code

SET LIBRARY TO ACTIIDLE
WAIT WINDOW TO m.test TIMEOUT 5
SET LIBRARY TO

C Code

#include <pro_ext.h>

static unsigned IdlerID;

//   This is the routine that is registered as an idle event handler.
void FAR IdleHandler(WHandle wh, EventRec *ev)
{
   _PutStr("\nIdleHandler() called.");
}

void FAR Activate(ParamBlk FAR *parm)
{
   IdlerID = _ActivateIdle((FPFI) IdleHandler);
}

//   When the library is unloaded we must deactivate the idle event 
//   handlerin a CALLONUNLOAD function.
void FAR DeActivate(ParamBlk FAR *parm)
{
   _DeActivateIdle(IdlerID);
}

FoxInfo myFoxInfo[] = {
   {"ACTIVATE",  (FPFI) Activate, CALLONLOAD,   ""},
   {"DEACTIVATE",  (FPFI) DeActivate, CALLONUNLOAD, ""}
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

_DeActivateIdle( ) API Library Routine | _FindWindow( ) API Library Routine | _GlobalToLocal( ) API Library Routine | _MousePos( ) API Library Routine | Event Handlers | EventHandler( ) Function