Frank Applin
|
How to swap images using a label
|
Frank Applin
07/26/2012 11:50 AM
post94434
|
How to swap images using a label
Hi,
I'm new to QNX and PhAB, but have been programming for 20+ years. I guess I'm most familiar with the Visual Studio
paradigm.
I am using Neil Carter's example of showing an image using a label.
int ShowImage( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
PhImage_t *myImg;
char myImgFlnm[20] = "PICTURE.BMP";
/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
if ((myImg = PxLoadImage( myImgFlnm, NULL)) == NULL) {
fprintf( stderr, "Error loading image file %s\n", myImgFlnm);
PtExit( EXIT_FAILURE );
}
PtSetResource(ABW_lblMyImg, Pt_ARG_LABEL_IMAGE, myImg, 0);
return( Pt_CONTINUE );
}
How can I swap out the current image with another image after a short delay?
I tried the following, but it simple shows the 2nd image:
int ShowImage( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
PhImage_t *myImg, *myImg2;
char myImgFlnm[20] = "PICTURE.BMP";
char myImgFlnm2[20] = "PICTURE2.BMP";
/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
if ((myImg = PxLoadImage( myImgFlnm, NULL)) == NULL) {
fprintf( stderr, "Error loading image file %s\n", myImgFlnm);
PtExit( EXIT_FAILURE );
}
PtSetResource(ABW_lblMyImg, Pt_ARG_LABEL_IMAGE, myImg, 0);
delay(5000); /* delay 5 secs */
if ((myImg2 = PxLoadImage( myImgFlnm2, NULL)) == NULL) {
fprintf( stderr, "Error loading image file %s\n", myImgFlnm2);
PtExit( EXIT_FAILURE );
}
PtSetResource(ABW_lblMyImg, Pt_ARG_LABEL_IMAGE, myImg2, 0);
return( Pt_CONTINUE );
}
Thanks,
Frank
|
|
|