Order that child windows are deleted

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

    • Order that child windows are deleted


      I'm looking into the intended behaviour of windows and child windows and the order that they are deleted. In the emWin documentation it states the following for WM_DeleteWindow():

      Before the window is deleted, it receives a WM_DELETE message. This message is typically used to delete any objects (widgets) it uses and to free memory dynamically
      allocated by the window.
      If the specified window has any existing child windows, these are automatically deleted before the window itself is deleted. Child windows therefore do not need to
      be separately deleted. Before the window will be deleted it sends a WM_NOTIFICATION_CHILD_DELETED
      message to its parent window.
      The way I would interpret this is that any child windows are deleted BEFORE the parent window is deleted. But the order that I receive the WM_DELETE messages are in the reverse order. First the parent window receives the WM_DELETE message, and then the child windows receive the WM_DELETE message. The problem I have with this is that, as stated by one of the SEGGER reps on this forum is that 'The WM_DELETE message will be the last message the parent ever receives before being deleted' when this is not the case. After the parent window has received the supposed final WM_DELETE message, it then subsequently will receive some WM_NOTIFICATION messages from the children being deleted. This also goes against my intuitive thoughts about the order in which this should happen, which is that the hierarchy should be deleted from the most nested node up to the least. Since the intent of WM_DELETE is to free any memory allocated in associated with the wind and if child windows can reference data held by the parent window, then you will face memory corruption issues.

      Any assistance is much appreciated!

      Thank you.