Delete old bitmap,display new bitmap

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

    • Delete old bitmap,display new bitmap

      Hello,
      I want to delete the previous bitmap and show the new bitmap.
      I used the callback function, but I couldn't.

      How can I do it.

      my code not work.

      static void _cbDialog(WM_MESSAGE * pMsg)
      {

      switch (pMsg->MsgId) {
      case WM_PAINT:
      GUI_DrawBitmap(&bitmap,x, y);
      break;
      }
      }

      void Callback(WM_MESSAGE * pMsg);
      void Callback(WM_MESSAGE * pMsg)
      {
      WM_HWIN hItem;

      switch (pMsg->MsgId) {
      case WM_PAINT:
      GUI_DrawBitmap(&newbitmap,x, y);
      break;
      default:
      WM_DefaultProc(pMsg);
      break;
      }
      }
    • Hi Hakan,

      you can use more than one callback for the same window, however it is not advisable in your case when there are very little differences between them.
      It would be best to just use one callback and decide in the WM_PAINT case which bitmap should be shown. This could be done with e.g. a guard, when a button is pressed, as shown below:

      C Source Code

      1. /*********************************************************************
      2. *
      3. * _cbBk
      4. */
      5. static void _cbBk(WM_MESSAGE * pMsg) {
      6. switch (pMsg->MsgId) {
      7. case WM_PAINT:
      8. GUI_SetBkColor(GUI_BLACK);
      9. GUI_Clear();
      10. if (ButtonPressed) {
      11. GUI_DrawBitmap(&Bitmap1, 0, 0);
      12. } else {
      13. GUI_DrawBitmap(&Bitmap2, 0, 0);
      14. }
      15. break;
      16. default:
      17. WM_DefaultProc(pMsg);
      18. break;
      19. }
      20. }
      21. /*********************************************************************
      22. *
      23. * Public code
      24. *
      25. **********************************************************************
      26. */
      27. /*********************************************************************
      28. *
      29. * MainTask
      30. */
      31. void MainTask(void) {
      32. GUI_Init();
      33. WM_SetCallback(WM_HBKWIN, _cbBk);
      34. while (1) {
      35. GUI_Delay(100);
      36. }
      37. }
      Display All

      Remember to redraw your window in order to show the new bitmap (WM_InvalidateWindow()).
      Also note that every callback needs a default case that calls WM_DefaultProc(pMsg) for normal windows and <WIDGET>_Callback(pMsg) for widgets.

      Best regards,

      Florian
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.