________________________________________________________________________
Applicable Environment
________________________________________________________________________
- Topic: Making a timeout with PtAlert
- SDP: 6.5.0, 6.4.0
- Target: Any supported target
________________________________________________________________________
Solution________________________________________________________________________
This sample code creates time out with the Photon PtAlert function.
Use PtTimer to destroy the Widget.
Example:
/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
/* Local headers */
#include "ablibs.h"
#include "abimport.h"
#include "proto.h"
static PtWidget_t *FrontChild;
int BtnCb( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ) {
/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
return Pt_CONTINUE;
}
int SetupCb( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ) {
char const *buttons[3] = { "Yes", "No", "Maybe" };
int btn;
/* eliminate 'unreferenced' warnings */
link_instance = link_instance, apinfo = apinfo, cbinfo = cbinfo;
/* Remember which widget (in base window) was originally in front */
FrontChild = PtWidgetChildFront( ABW_base );
switch ( btn = PtAlert( ABW_base, NULL, "title", NULL, "message", NULL, 3, buttons, NULL, 3, 2, Pt_CENTER | Pt_MODAL | Pt_RELATIVE ) ) {
case -1: printf( "Timeout!\n" ); break;
case 1:
case 2:
case 3: printf( "Button #%d: '%s'\n", btn, buttons[btn-1] ); break;
default: printf( "Unexpected: %d\n", btn ); break;
}
FrontChild = NULL;
return Pt_CONTINUE;
}
int TmrCb( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ) {
/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
if ( ( NULL != ( widget = PtWidgetChildFront( ABW_base ) ) ) && ( widget != FrontChild ) ) {
PtDestroyWidget( widget );
FrontChild = NULL;
}
return Pt_CONTINUE;
}
________________________________________________________________________
NOTE:
This entry has been validated against the SDP version listed above. Use
caution when considering this advice for any other SDP version. For
supported releases, please reach out to QNX Technical Support if you have any questions/concerns. ________________________________________________________________________