How to call GUI_Clear to clear the background so that next widow will be created smoothly

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

    • How to call GUI_Clear to clear the background so that next widow will be created smoothly

      Hi all,
      I want to understand how we can use GUI_clear() API and how it works. I have created one keypad window which has only numbers. 0-9, Back and enter button. now on press of enter button i need to create alphanumeric keypad which has many buttons.
      Problem is that when i am creating the second keypad by deleting the first one, the creation is not smooth i.e I can still see that clearing has not happened for first window. How can i achieve that?
      I have tried first deleting the window then set the color to black and call GUI_Clear() but this is not helping out. Is there any other way?

      Thanks
      Kusum Swarankar
    • Hi,

      This is most likely because the background window (WM_HBKWIN) does not "know" how to redraw itself.

      You can either set a color for WM_HBKWIN,

      C Source Code

      1. WM_SetDesktopColor(GUI_BLACK);

      or you set a custom callback function which manages the look of WM_HBKWIN:

      C Source Code

      1. #include "DIALOG.h"
      2. static void _cbBk(WM_MESSAGE * pMsg) {
      3. switch (pMsg->MsgId) {
      4. case WM_PAINT:
      5. GUI_SetBkColor(GUI_BLACK);
      6. GUI_Clear();
      7. break;
      8. default:
      9. WM_DefaultProc(pMsg);
      10. break;
      11. }
      12. }
      13. void MainTask(void) {
      14. GUI_Init();
      15. WM_SetCallback(WM_HBKWIN, _cbBk);
      16. while (1) {
      17. GUI_Delay(100);
      18. }
      19. }
      Display All

      Regards,
      Sven
      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.
    • Hi Sven,
      Thanks for the quick reply. So when should i set the call back to desktop window? before creating any other window?
      I tried setting this callback before creating the second keypad in my situation which i explained above. still behavior is same.