Paint issues with 2 windows and same callback function

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

    • Paint issues with 2 windows and same callback function

      Hello,

      I have two dialog boxes one larger one which fills the whole screen 800x480 other smaller one which is like a prompt window placed at center of the screen.
      Both these dialog boxes have same callback function and i have respective functions to call on paint event received
      let us use window1 and window2 for reference.

      i maintain the indexes of the windows. when only the window1 is shown then respective onpaint is called and it is drawn ok. i call a function on button release event to create and show window2 on top of window1. Then window 2 is drawn and respective onpaint function is called. the background of the window2 i.e. window1 is not drawn ok.

      I have attached an image of the screen. the gray area is the background of window1 and white area is window2.
      When window 2 is created an extra white area is drawn as shown which should not be drawn.

      The window1 contains normal buttons and images plus knob widget.
      code on paint window 1 is

      GUI_SetBkColor(BACK_COLOR);
      GUI_Clear();
      //other drawing operations

      The window2 contains texts and buttons
      the code in on paint window 2 is

      GUI_SetBkColor(BACK_COLOR);
      GUI_Clear();

      // Rounded corner dialog box. this is used for window2
      guiRect_STYP pRect;
      GetClientRect(&pRect);
      GUI_FillRoundedRect(pRect.x0, pRect.y0, pRect.x1, pRect.y1, ROUNDED_CORNER_RADIUS);
      GUI_SetColor(COLOR_6);

      // Draw horizontal and vertical line for buttons.
      GUI_SetPenShape(GUI_PS_FLAT);
      GUI_DrawVLine(VERTICAL_LINE_X_POSITION, VERTICAL_LINE_START_POSITION, VERTICAL_LINE_END_POSITION);
      GUI_DrawHLine(HORIZONTAL_LINE_X_POSITION, HORIZONTAL_LINE_START_POSITION, HORIZONTAL_LINE_END_POSITION);

      note that the callback function used is same in both cases and only different paint functions are called.

      Thanks
      Regards,

      Anuj
      Images
      • Capture2.PNG

        8.56 kB, 608×358, viewed 66 times
    • Hi,

      Thanks for your reply,

      I am sorry i cannot share any code. But I found the root cause. when i hide the knob widget from the background window and then call createwindow2 to create the smaller window then the extra rectangle is not observed.

      if i do not hide the knob widget then instead of GetClientRect(&pRect) called in window 2 paint i used WM_GetWindowRectEx() to get coordinates of the actual window i.e. smaller window by passing the window handle. this works and i do not get the extra rectangle.

      Not sure why GetClientRect is not working in this case.
      Any thoughts or suggestions on this.

      Thanks
      Regards

      Anuj
    • Hi

      I was able to achieve what i wanted but facing a issue with Knob transparency.
      Please see the image attached. When the white window is shown on save button click then the transparency of knob widget in background window disappears. for the knob widget i have created a memdev

      when the window 1 is shown initially the knob is drawn ok with transparency but disappears with new window shown.

      The background window knob widget initialization is below,

      hKnob = GetWindowItem(pMessage->hWin, GUI_ID_KNOB_0);
      hMem = MEMDEV_CreateFixed32(SETPOINT_MGR_SCR_MEMDEV_POS_X, SETPOINT_MGR_SCR_MEMDEV_POS_Y, 225, 225);
      (void)MEMDEV_Select(hMem);
      (void)GUI_SetBkcolor(GUI_TRANSPARENT);
      GUI_Clear();
      DrawBitmap(&bmdial, SETPOINT_MGR_SCR_MEMDEV_DIAL_POS_X, SETPOINT_MGR_SCR_MEMDEV_DIAL_POS_Y);

      (void)MEMDEV_Select(0);
      KNOB_SetMemDevice(hKnob, hMem);

      but when the window 2 is shown above the background grayish window then the knob is not drawn with transparency.

      Please note that once the window 2 is shown the paint function of background grayish window is not called. is it due to this?
      how do i resolve this issue.

      Thanks
      Regards,

      Anuj
      Images
      • img.png

        10.17 kB, 815×501, viewed 55 times