Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. ERROR - Object deleted before window was destroyed

ERROR - Object deleted before window was destroyed

Scheduled Pinned Locked Moved ATL / WTL / STL
helpc++tutorialquestionlearning
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kcynic
    wrote on last edited by
    #1

    Im a beginner of WTL. I want to subclass a CStatic control, my code is very simple like following: class CMyStatic : public CWindowImpl(CMyStatic,CStatic) { BEGIN_MSG_MAP_EX( CMyStatic) //message handle macros here END_MSG_MAP( ) //there are message implements } And, in the main dialog window, I use SubclassWindow function to subclass a spcified static control. But, the problem iss, when the main dialog is closing, i would get an atl assert: ERROR - Object deleted before window was destroyed. I know the problem is due to the deconstructor of its base class. It's deleted before the window has been destroyed. So, how to fix it?

    S 1 Reply Last reply
    0
    • K kcynic

      Im a beginner of WTL. I want to subclass a CStatic control, my code is very simple like following: class CMyStatic : public CWindowImpl(CMyStatic,CStatic) { BEGIN_MSG_MAP_EX( CMyStatic) //message handle macros here END_MSG_MAP( ) //there are message implements } And, in the main dialog window, I use SubclassWindow function to subclass a spcified static control. But, the problem iss, when the main dialog is closing, i would get an atl assert: ERROR - Object deleted before window was destroyed. I know the problem is due to the deconstructor of its base class. It's deleted before the window has been destroyed. So, how to fix it?

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      Unsubclass[^] the window in a WM_CLOSE handler?

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      K 2 Replies Last reply
      0
      • S Stuart Dootson

        Unsubclass[^] the window in a WM_CLOSE handler?

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        K Offline
        K Offline
        kcynic
        wrote on last edited by
        #3

        You means Unsubclass the child control in its parent's WM_CLOSE message handler? Yes, i calls myContrl.UnSubclassWindow() before EndDialog() call.

        1 Reply Last reply
        0
        • S Stuart Dootson

          Unsubclass[^] the window in a WM_CLOSE handler?

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

          K Offline
          K Offline
          kcynic
          wrote on last edited by
          #4

          Im sorry, its my fault, i had declared two such controls, but unsubclssed only one. its ok now. Regards.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups