drawing a gif wihtin a dialog

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • drawing a gif wihtin a dialog

    Hello,
    I have to show a wait animation with a gif file within a dialog. All available examples draw this gif file with the sub images within on while loop. My idea was to use a timer within the callback of the dialog. But until now i was not able to draw the gif in the expected way.

    How can I draw the gif file within a dialog using the callback and a timer?

    thank you
    markus
  • Hello Adrian,

    have tried it in the following way.
    I can then see the "movie" but it don't look like it should. It looks like that all pictures are drawn above the other.

    C Source Code

    1. static const GUI_WIDGET_CREATE_INFO _aMainCreate [ ] = {
    2. { WINDOW_CreateIndirect, "", ID_WINDOW_0, 0, 0, 320, 240, 0, 0, 0 },
    3. };
    4. //==========================================================================
    5. static void _cbMain ( WM_MESSAGE * pMsg )
    6. {
    7. WM_HWIN hItem;
    8. int Id, NCode;
    9. static WM_HTIMER hTimer;
    10. static GUI_GIF_INFO GifInfo = { 0 }; /* Info structure of GIF file */
    11. static int j = 0;
    12. switch ( pMsg->MsgId )
    13. {
    14. case WM_TIMER :
    15. if ( j < GifInfo.NumImages )
    16. {
    17. j ++;
    18. }
    19. else
    20. {
    21. j = 0;
    22. }
    23. WM_InvalidateWindow(pMsg->hWin);
    24. WM_RestartTimer ( hTimer, 1000 );
    25. break;
    26. case WM_PAINT :
    27. GUI_GIF_DrawSub ( ( char * ) acInProgress, sizeof( acInProgress ), 100, 100, j ); /* Draw sub image */
    28. break;
    29. case WM_INIT_DIALOG :
    30. hItem = pMsg->hWin;
    31. hTimer = WM_CreateTimer(hItem,0,1000,0);
    32. GUI_GIF_GetInfo ( ( char * ) acInProgress, sizeof( acInProgress ), &GifInfo ); /* Get GIF info structure */
    33. j = 0;
    34. break;
    35. default :
    36. WM_DefaultProc ( pMsg );
    37. break;
    38. }
    39. }
    40. //==========================================================================
    41. void CreateMainWindow ( void )
    42. {
    43. WM_HWIN hWin;
    44. hWin = GUI_CreateDialogBox ( _aMainCreate, GUI_COUNTOF(_aMainCreate), &_cbMain, WM_HBKWIN, 0, 0 );
    45. }
    Display All
  • Hello,

    Yes, of course. GIF sub images can be of different sizes. Therefor it might be necessary to clear the screen. Further you will have to get the image information of each sub image in order to be able to display it at the proper x- and y-positions.

    Best regards,
    Adrian