Text not displaying after hiding widget

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

    • Text not displaying after hiding widget

      Hi all,

      I am trying to create a splash screen for one of my projects. I am using widgets to display logo, progress bar and then trying to display test after hiding widget with logo and deleting progress bar. For some reason I don't see any text being displayed. I do not want logo to be displayed when I am trying to display text. Is there a work around for this?


      Thank you!

      Source Code

      1. static void _cbDialog(WM_MESSAGE * pMsg) {
      2. const void * pData;
      3. WM_HWIN hItem;
      4. U32 FileSize;
      5. PROGBAR_Handle hProgBar;
      6. int i;
      7. // USER START (Optionally insert additional variables)
      8. // USER END
      9. switch (pMsg->MsgId) {
      10. case WM_INIT_DIALOG:
      11. //
      12. // Initialization of 'Window'
      13. //
      14. hItem = pMsg->hWin;
      15. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00000000));
      16. //
      17. // Initialization of 'Image'
      18. //
      19. hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_0);
      20. pData = _GetImageById(ID_IMAGE_0_IMAGE_0, &FileSize);
      21. IMAGE_SetBMP(hItem, pData, FileSize);
      22. GUI_Delay(3000);
      23. WM_HideWin(hItem);
      24. hProgBar = PROGBAR_Create(120, 200, 100, 10, WM_CF_SHOW);
      25. /* Modify progress bar */
      26. for (i = 0; i <= 100; i++)
      27. {
      28. PROGBAR_SetValue(hProgBar, i);
      29. GUI_Delay(30);
      30. }
      31. GUI_Delay (400);
      32. WM_DeleteWindow(hProgBar);
      33. GUI_ClearRect(0, 50, 319, 239);
      34. GUI_Delay(750);
      35. GUI_SetFont(GUI_FONT_8X16X3X3);
      36. GUI_SetBkColor(GUI_BLACK);
      37. GUI_SetColor(GUI_DARKBLUE);
      38. GUI_DispStringAt("SENTINEL O", 30, 80);
      39. GUI_SetFont(GUI_FONT_32B_1);
      40. GUI_DispDecAt(2,270,95,1);
      41. GUI_SetFont(GUI_FONT_10_1);
      42. GUI_SetColor(GUI_GRAY);
      43. GUI_DispStringAt("COPYRIGHT 2019",120,220);
      44. // USER START (Optionally insert additional code for further widget initialization)
      45. // USER END
      46. break;
      47. // USER START (Optionally insert additional message handling)
      48. // USER END
      49. default:
      50. WM_DefaultProc(pMsg);
      51. break;
      52. }
      53. }
      54. /*********************************************************************
      55. *
      56. * Public code
      57. *
      58. **********************************************************************
      59. */
      60. /*********************************************************************
      61. *
      62. * CreateWindow
      63. */
      64. WM_HWIN CreateWindow(void);
      65. WM_HWIN CreateWindow(void) {
      66. WM_HWIN hWin;
      67. hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      68. return hWin;
      69. }
      Display All
    • Hello,

      function for displaying text GUI_DispStringAt() is the drawing function and you should use any drawing functions in WM_PAINT message handler of your dialog.

      When you use GUI_Delay() from WM_INIT_DIALOG it calls dialog update and you see the result of PROGBAR_SetValue()/WM_HideWin().

      It is recommended to use GUI_Exec()/GUI_Delay() from the separate task. But if you want to do it your way, then use a custom flag and pass it to the WM_PAINT handler.

      C Source Code

      1. int _DispText = 0;
      2. static void _cbDialog(WM_MESSAGE * pMsg) {
      3. const void * pData;
      4. WM_HWIN hItem;
      5. U32 FileSize;
      6. PROGBAR_Handle hProgBar;
      7. int i;
      8. // USER START (Optionally insert additional variables)
      9. // USER END
      10. switch (pMsg->MsgId) {
      11. case WM_INIT_DIALOG:
      12. //
      13. // Initialization of 'Window'
      14. //
      15. hItem = pMsg->hWin;
      16. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00000000));
      17. //
      18. // Initialization of 'Image'
      19. //
      20. hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_0);
      21. pData = _GetImageById(ID_IMAGE_0_IMAGE_0, &FileSize);
      22. IMAGE_SetBMP(hItem, pData, FileSize);
      23. GUI_Delay(3000);
      24. WM_HideWin(hItem);
      25. hProgBar = PROGBAR_Create(120, 200, 100, 10, WM_CF_SHOW);
      26. /* Modify progress bar */
      27. for (i = 0; i <= 100; i++)
      28. {
      29. PROGBAR_SetValue(hProgBar, i);
      30. GUI_Delay(30);
      31. }
      32. GUI_Delay (400);
      33. WM_DeleteWindow(hProgBar);
      34. //GUI_ClearRect(0, 50, 319, 239); // not needed
      35. GUI_Delay(750);
      36. _DispText = 1;
      37. // USER START (Optionally insert additional code for further widget initialization)
      38. // USER END
      39. break;
      40. // USER START (Optionally insert additional message handling)
      41. case WM_PAINT:
      42. if (_DispText) {
      43. GUI_SetFont(GUI_FONT_8X16X3X3);
      44. GUI_SetBkColor(GUI_BLACK);
      45. GUI_SetColor(GUI_DARKBLUE);
      46. GUI_DispStringAt("SENTINEL O", 30, 80);
      47. GUI_SetFont(GUI_FONT_32B_1);
      48. GUI_DispDecAt(2,270,95,1);
      49. GUI_SetFont(GUI_FONT_10_1);
      50. GUI_SetColor(GUI_GRAY);
      51. GUI_DispStringAt("COPYRIGHT 2019",120,220);
      52. }
      53. else
      54. WM_DefaultProc(pMsg);
      55. break;
      56. // USER END
      57. default:
      58. WM_DefaultProc(pMsg);
      59. break;
      60. }
      61. }
      62. /*********************************************************************
      63. *
      64. * Public code
      65. *
      66. **********************************************************************
      67. */
      68. /*********************************************************************
      69. *
      70. * CreateWindow
      71. */
      72. WM_HWIN CreateWindow(void);
      73. WM_HWIN CreateWindow(void) {
      74. WM_HWIN hWin;
      75. hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      76. return hWin;
      77. }
      Display All
      Alex.

      The post was edited 1 time, last by LexaGB ().

    • Alex,

      Thank you for your help with that. I tried it out. I still can't see the text after progress bar. I don't understand why. But I gave this following code a try and it works.

      Source Code

      1. static void _cbDialog(WM_MESSAGE * pMsg) {
      2. const void * pData;
      3. WM_HWIN hItem;
      4. U32 FileSize;
      5. PROGBAR_Handle hProgBar;
      6. int i;
      7. // USER START (Optionally insert additional variables)
      8. // USER END
      9. switch (pMsg->MsgId) {
      10. case WM_INIT_DIALOG:
      11. //
      12. // Initialization of 'Window'
      13. //
      14. hItem = pMsg->hWin;
      15. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00000000));
      16. // Initialization of 'Image'
      17. hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_0);
      18. pData = _GetImageById(ID_IMAGE_0_IMAGE_0, &FileSize);
      19. IMAGE_SetBMP(hItem, pData, FileSize);
      20. GUI_Delay(2000);
      21. WM_HideWin(hItem); // Hide Image
      22. GUI_Delay(500);
      23. //Initialisation of Progress Bar
      24. hProgBar = PROGBAR_Create(100, 200, 100, 10, WM_CF_SHOW);
      25. /* Modify progress bar */
      26. for (i = 0; i <= 100; i++)
      27. {
      28. PROGBAR_SetValue(hProgBar, i);
      29. GUI_Delay(30);
      30. }
      31. GUI_Delay (400);
      32. WM_DeleteWindow(hProgBar); // Delete Progress Bar
      33. GUI_ClearRect(0, 50, 319, 239);
      34. GUI_Delay(50);
      35. hItem = pMsg->hWin;
      36. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00000000));
      37. //
      38. // Initialization of 'Text'
      39. //
      40. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
      41. TEXT_SetText(hItem, "SENTINEL O");
      42. TEXT_SetFont(hItem, GUI_FONT_8X16X3X3);
      43. TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FF0000));
      44. //
      45. // Initialization of 'Text'
      46. //
      47. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
      48. TEXT_SetText(hItem, "COPYRIGHT 2019");
      49. TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00C0C0C0));
      50. // Initialization of 'Text'
      51. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
      52. TEXT_SetText(hItem, "2");
      53. TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FF0000));
      54. TEXT_SetFont(hItem, GUI_FONT_32B_1);
      55. // USER START (Optionally insert additional code for further widget initialization)
      56. // USER END
      57. break;
      58. // USER START (Optionally insert additional message handling)
      59. // USER END
      60. default:
      61. WM_DefaultProc(pMsg);
      62. break;
      63. }
      64. }
      65. /*********************************************************************
      66. *
      67. * Public code
      68. *
      69. **********************************************************************
      70. */
      71. /*********************************************************************
      72. *
      73. * CreateWindow
      74. */
      75. WM_HWIN CreateWindow(void);
      76. WM_HWIN CreateWindow(void) {
      77. WM_HWIN hWin;
      78. hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      79. return hWin;
      80. }
      Display All
    • Works on my side, at first glance, in simulation version 5.44. Maybe additional code from your project affects the text visibility.

      Your new code using TEXT widgets instead of drawing text in WM_PAINT of the dialog. This updates the contains of the TEXT widgets in their WM_PAINTs when invalidating the dialog and its child widgets, and all the text drawing functions are called from the right places. Thus you can see the text in your dialog.

      Alex.