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. Control's window not ready even in FinalConstruct()

Control's window not ready even in FinalConstruct()

Scheduled Pinned Locked Moved ATL / WTL / STL
c++comquestion
5 Posts 4 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.
  • G Offline
    G Offline
    greekgoddj
    wrote on last edited by
    #1

    Hello, Things only seem to get stranger everyday. If I am not mistaken, in an ATL ActiveX Control, the aim of FinalConstruct is that by the time the program reaches there, the object has alreay been created. however that does not seem to be the case. In FinalConstructor() m_hWnd in the next statement is NULL. CWnd* parent = CWnd::FromHandle(this->m_hWnd); How can the control's window not exist after the constructor has been completed? Placing the same statment in the OnDraw function works, but not in FinalConstruct()? Am I missing something? Is there some sort of FinalNoReallyThisOneIsTheFinalConstruct() ? :wtf: Thanks

    M J A 3 Replies Last reply
    0
    • G greekgoddj

      Hello, Things only seem to get stranger everyday. If I am not mistaken, in an ATL ActiveX Control, the aim of FinalConstruct is that by the time the program reaches there, the object has alreay been created. however that does not seem to be the case. In FinalConstructor() m_hWnd in the next statement is NULL. CWnd* parent = CWnd::FromHandle(this->m_hWnd); How can the control's window not exist after the constructor has been completed? Placing the same statment in the OnDraw function works, but not in FinalConstruct()? Am I missing something? Is there some sort of FinalNoReallyThisOneIsTheFinalConstruct() ? :wtf: Thanks

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      greekgoddj wrote: How can the control's window not exist after the constructor has been completed? Because the C++ object and the window have different lifetimes. The C++ object is created before the window is. FinalConstruct() is, as the name implies, part of the construction process, so only the C++ exists when it is called. --Mike-- LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD

      1 Reply Last reply
      0
      • G greekgoddj

        Hello, Things only seem to get stranger everyday. If I am not mistaken, in an ATL ActiveX Control, the aim of FinalConstruct is that by the time the program reaches there, the object has alreay been created. however that does not seem to be the case. In FinalConstructor() m_hWnd in the next statement is NULL. CWnd* parent = CWnd::FromHandle(this->m_hWnd); How can the control's window not exist after the constructor has been completed? Placing the same statment in the OnDraw function works, but not in FinalConstruct()? Am I missing something? Is there some sort of FinalNoReallyThisOneIsTheFinalConstruct() ? :wtf: Thanks

        J Offline
        J Offline
        Jorgen Sigvardsson
        wrote on last edited by
        #3

        Try trapping the WM_CREATE message. Or WM_INITDIALOG if you're using a dialog based window. -- My name in Katakana is ヨルゲン. My name in German is Jörgen. I blog too now[^]

        G 1 Reply Last reply
        0
        • J Jorgen Sigvardsson

          Try trapping the WM_CREATE message. Or WM_INITDIALOG if you're using a dialog based window. -- My name in Katakana is ヨルゲン. My name in German is Jörgen. I blog too now[^]

          G Offline
          G Offline
          greekgoddj
          wrote on last edited by
          #4

          Yup....the solution is... LRESULT CKnob::OnShowWindow(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) Thats where the window is already created and ready. Needed to overide that and add my code inside there. Thanks! ;P

          1 Reply Last reply
          0
          • G greekgoddj

            Hello, Things only seem to get stranger everyday. If I am not mistaken, in an ATL ActiveX Control, the aim of FinalConstruct is that by the time the program reaches there, the object has alreay been created. however that does not seem to be the case. In FinalConstructor() m_hWnd in the next statement is NULL. CWnd* parent = CWnd::FromHandle(this->m_hWnd); How can the control's window not exist after the constructor has been completed? Placing the same statment in the OnDraw function works, but not in FinalConstruct()? Am I missing something? Is there some sort of FinalNoReallyThisOneIsTheFinalConstruct() ? :wtf: Thanks

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            In virtula method FinalConstruct() is control created in sense of com object. Creation of control (window) is performed in method OnCreate(...) (this is message handler of message WM_CREATE like in common window).

            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