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