Able to display text before loading a widget but not after deleting a window

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

    • Able to display text before loading a widget but not after deleting a window

      Hi,

      So, I have been using emWin and learning a lot about it. But I came across something which I don't understand. Can someone please help me with this?

      1. I display text using GUI_DispStringAt() and I can see it.
      2. Clear the text and display a window with buttons and textbox.
      3. Clear the window and trying to display text using GUI_DispString() and I don't see anything on the screen.

      Has anyone come across this issue? Am I doing something wrong here?

      Note: When I tried to use a text box to display string, I can display text.

      Any help is appreciated.

      Best regards,
      BMD
    • Hi,

      you have to make sure that the window that shows the text gets redrawn again. If you just display text, e.g. in your main task, and something else is drawn above the text, the text will be gone because it will not be redrawn again. I'm assuming you displayed the text in the "background window", which per default when it is redrawn, simply fills the entire screen with black.

      The text should be drawn in a window callback (WM_PAINT). That does not have to be a new window, it can be the background window as well. When emWin then tells the window to redraw itself (like when a window on top got deleted), we land in the WM_PAINT case of that window again and the drawing operations are executed.

      If your text is drawn in the background window, this would be the way you would do it:

      C Source Code

      1. /*********************************************************************
      2. *
      3. * Static code
      4. *
      5. **********************************************************************
      6. */
      7. /*********************************************************************
      8. *
      9. * _cbBk
      10. */
      11. static void _cbBk(WM_MESSAGE * pMsg) {
      12. switch(pMsg->MsgId) {
      13. case WM_PAINT:
      14. //
      15. // Clear window.
      16. //
      17. GUI_SetBkColor(GUI_BLACK);
      18. GUI_Clear();
      19. //
      20. // Display text.
      21. //
      22. GUI_DispString("Some text");
      23. break;
      24. default:
      25. WM_DefaultProc(pMsg);
      26. }
      27. }
      28. /*********************************************************************
      29. *
      30. * Public code
      31. *
      32. **********************************************************************
      33. */
      34. /*********************************************************************
      35. *
      36. * MainTask
      37. */
      38. void MainTask(void) {
      39. //
      40. // Init emWin.
      41. //
      42. GUI_Init();
      43. //
      44. // Set callback to background window.
      45. //
      46. WM_SetCallback(WM_HBKWIN, _cbBk);
      47. while (1) {
      48. GUI_Delay(100);
      49. }
      50. }
      Display All
      I hope this brought some clarity to your issue.

      Best regards,

      Florian