I'm trying to do a simple clock using labels and I want to update a label, however, I'm having trouble getting it to display. I have an init_clock function and an update_clock function. I place lite_new_label in init_clock and I do not see anything, but when I move lite_new_label to the main() function then it displays and updates fine. Is there a reason for this or am I doing something wrong? Here is my code for that:
typedef struct { LiteLabel *label; time_t now; // Our current time struct tm *Tm; // Our Time structure char data[10]; } MainClock; static DFBResult init_clock( MainClock *ourclock, LiteWindow *window ) { DFBResult ret; DFBRectangle rect = { 250, 6, 65, 0 }; ret = lite_new_label( LITE_BOX(window) ,&rect, liteNoLabelTheme, 12, &ourclock->label ); if (ret) { D_DERROR( ret, "lite_new_label( %d,%d - %dx%d ) failed!\n", rect.x, rect.y, rect.w, rect.h ); return ret; } //Time Functions ourclock->now = time( &ourclock->now ); // Get current time ourclock->Tm = localtime( &ourclock->now ); // Parse time data strftime( ourclock->data, 10, "%H:%M:%S", ourclock->Tm ); //Convert time to string //set time label lite_set_label_font( ourclock->label, "VeraSe", LITE_FONT_BOLD, 12, DFFA_NONE ); printf("%s\n", ourclock->data); return lite_set_label_text( ourclock->label, ourclock->data ); } static DFBResult update_clock( MainClock *ourclock ) { //Time Functions ourclock->now = time( &ourclock->now ); // Get current time ourclock->Tm = localtime( &ourclock->now ); // Parse time data strftime( ourclock->data, 10, "%H:%M:%S", ourclock->Tm ); //Convert time to string printf("%s\n", ourclock->data); return lite_set_label_text( ourclock->label, ourclock->data ); } V/r, Bryan _______________________________________________ directfb-users mailing list directfb-users@directfb.org http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users