Bottom window not rendered correctly

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

  • Bottom window not rendered correctly

    Hello!

    I have two windows, one bottom with a loaded bitmap, and one as a child of the bottom. I change the size and background colour of the top window according to user input. Everything is fine, until the top window changes its place in the direction of the X axis. Then the bottom window's pixels are corrupted until. Invalidating and WM_Paint function does not help at all.
    In the direction of Y axis, everything is fine.

    Do you have any idea?

    By the way I woud like to realise a background picture and a layer above which can show up a resizeable rectangle. Do you know a better way to do it? I tried to use layers, but was not able to make working transparent layer support...

    Thanks for your answer.
  • Hello,

    Please make sure that all drawing operations are performed from within the WM_PAINT event of the respective window. Please note that multiple layers require hardware support. In order to display a resizeable rectangle, I would recommend using a simple window.

    Details can be found in the chapter "The Window Manager (WM)" and "MultiLayer / MultiDisplay support" in the emWin user manual.

    Best regards,
    Adrian
  • I'm using _hWindow0 for displaying a background image. The user function is HMI_SetPicture. All drawing operations happen in _cbWindow0.
    _hWindow1 is used for displaying a rectangle (as a resizeable windows with a defined bkg color). The user function is HMI_SetRectangle. All drawing operations happen in _cbWindow1.
    The parent for both windows is the bkg parent.

    C Source Code

    1. /******************************************************************************/
    2. /* Definition of local functions */
    3. /******************************************************************************/
    4. static void _cbWindow0(WM_MESSAGE * pMsg)
    5. {
    6. switch (pMsg->MsgId)
    7. {
    8. case WM_PAINT:
    9. if (glob_pict_ind == 0)
    10. {
    11. GUI_Clear();
    12. }
    13. else if (glob_pict_ind > 0 && glob_pict_ind <= HMI_BMP_MAX)
    14. {
    15. GUI_DrawBitmap(bmp_array[glob_pict_ind], glob_pict_x, glob_pict_y);
    16. }
    17. else if (glob_pict_ind > HMI_BMP_MAX)
    18. {
    19. display_error();
    20. }
    21. break;
    22. default:
    23. WM_DefaultProc(pMsg);
    24. }
    25. }
    26. static void _cbWindow1(WM_MESSAGE * pMsg)
    27. {
    28. GUI_ALPHA_STATE AlphaState;
    29. switch (pMsg->MsgId)
    30. {
    31. case WM_PAINT:
    32. GUI_SetBkColor(glob_color_rect);
    33. GUI_Clear();
    34. break;
    35. default:
    36. WM_DefaultProc(pMsg);
    37. }
    38. }
    39. /******************************************************************************/
    40. /* Definition of exported functions */
    41. /******************************************************************************/
    42. void HMI_init(void)
    43. {
    44. GUI_Init();
    45. WM_SetCreateFlags(WM_CF_MEMDEV);
    46. GUI_Clear();
    47. glob_pict_ind = 0;
    48. _hWindow0 = WM_CreateWindowAsChild(0, 0, 160, 128, 0, WM_CF_SHOW | WM_CF_MEMDEV, _cbWindow0, 0);
    49. _hWindow1 = WM_CreateWindowAsChild(0, 0, 160, 128, _hWindow0, WM_CF_MEMDEV, _cbWindow1, 0);
    50. }
    51. void HMI_SetPicture(u8 index, u8 x, u8 y)
    52. {
    53. glob_pict_ind = index;
    54. glob_pict_x = x;
    55. glob_pict_y = y;
    56. WM_InvalidateWindow(_hWindow0);
    57. }
    58. void HMI_SetRectangle(u8 x0, u8 y0, u8 x1, u8 y1, u32 color)
    59. {
    60. WM_SetWindowPos(_hWindow1,x0,y0,x1,y1);
    61. glob_color_rect = color;
    62. WM_ShowWindow(_hWindow1);
    63. }
    Display All


    Now the problem is that, when I call multiple times the HMI_SetPicture function, so more than one pictures are drawn in the _hWindow0 and I change the _hWindow1 size from for eg. 160x128 (full picture) to 160x10, than the _hWindow0 is not redrawed, and stays with the bkgcolor of _hWindow1. However the pictures drawn out for the second time with HMI_SetPicture are seeable.
  • Hello,

    Unfortunately I am not sure what the problem is. In general all invalid windows should be redrawn. In case one window is completely covered by another one, the covered window is not redrawn, unless the covering window has transparency.

    Best regards,
    Adrian