Drawing a transparent child window above the parent which has a GUI_PNG_Draw in WM_Paint results in inconsistent UI

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

    • Drawing a transparent child window above the parent which has a GUI_PNG_Draw in WM_Paint results in inconsistent UI

      First created a window : parentWindow.(0, 0, 480, 272)
      In this parentWindow's WM_PAINT: Using GUI_PNG_Draw posted a background image to the complete window
      In parentWindows's WM_CREATE: created a child window: childWindow with window Flags WM_CF_HASTRANS | WM_CF_SHOW (140, 11, 100, 250)
      In child window's WM_PAINT used GUI_AA_DrawArc to draw an arc every second (also used WM_TIMER)

      The child window is transparent but the behavior is becoming inconsistent after few seconds...
      Please help
    • Hello,

      I tried to reproduce your behavior but for me the arc remained consistent (see attached file).

      Can you send me your code or a sample so I can reproduce your error?

      Best regards,

      Florian
      Files
      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.
    • Hello,

      Thank you Florian, the mistake I was doing is setting the parent window to WM_CF_TRANS and not the child.

      But now I'm facing one more issue:
      When I try to display any text in childWindow using GUI_SetTextMode(GUI_TM_TRANS)... it starts overlapping.
      If I use GUI_Clear(), then it is repainting the child window with black color and transparency is lost
      Files
    • Hi,

      it is overlapping, because the background isn't redrawn. The parent window is missing a WM_PAINT case in _cbParent() that cleares the window.

      C Source Code

      1. case WM_PAINT:
      2. GUI_SetBkColor(GUI_BLACK);
      3. GUI_Clear();
      4. break;

      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.
    • Hi,

      But if it clear the parent window now, the image will be covered by this black parent window.

      Also, if I draw the png image again in WM_PAINT of parent window after GUI_Clear, won't it be memory intensive??
    • Hi,

      Raunaq wrote:

      But if it clear the parent window now, the image will be covered by this black parent window.
      that is correct, but since the parent window does not have the WM_CF_HASTRANS flag, it will cover the image displayed in the main window anyway.

      Instead of adding the WM_PAINT case to _cbParent(), changing the window flags to WM_CF_SHOW | WM_CF_HASTRANS should fix the problem.

      C Source Code

      1. hParent = WM_CreateWindowAsChild(8, 11, 464, 250, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbParent, 0);


      Although, currently the parent window has no use except creating the child window. You could just directly create the child window as a child of the main window and have the same result, but a simpler window structure.

      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.