WM_DeleteWindow() during WM_TOUCH_CHILD processing

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

    • WM_DeleteWindow() during WM_TOUCH_CHILD processing

      I have a Window that is a child of the background. It has many child widgets.

      When the user press the Window, a WM_TOUCH_CHILD message is propagated to the background callback. There I delete the Window, but the application crashes, I think because WM is trying to send other messages (related to the touch) to the widgets that were already deleted.

      So the question is: how to delete a child Window when the touch is released on whatever point? I would like to not edit the child window code, only the parent code.
    • Hi,

      I was able to reproduce your issue. You are correct, the error occurs because the window still receives messages after being deleted.

      You can react on WM_TOUCH in the window that is to be deleted. When the window is touched and the state is pressed, you can safely delete the window:

      C Source Code

      1. GUI_PID_STATE * pState;
      2. [...]
      3. case WM_TOUCH:
      4. pState = (GUI_PID_STATE *)pMsg->Data.p;
      5. if (pState->Pressed) {
      6. WM_DeleteWindow(pMsg->hWin);
      7. }
      8. 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.
    • SEGGER - Florian wrote:

      You can react on WM_TOUCH in the window that is to be deleted. When the window is touched and the state is pressed, you can safely delete the window:
      I didn't want to change the code of the winodow that is to be deleted, but if it's the only solution.

      Anyway I would like to delete the window on the unpressed event.