I've got this code in the InitInstance function of a class that extends WinApp:
m_pMainWnd = &m_Frame; // Clearly setting m_pMainWnd to !NULL
m_Frame.LoadFrame(BMP_ICON, 0, NULL, NULL);
m_pMainWnd->GetMenu()->Detach();
m_pMainWnd->SetMenu(NULL);
m_Frame.ShowWindow(SW_SHOW);
m_Frame.UpdateWindow();
Yet when running, the app opens, displays the m_Frame for like a millisecond and then closes again. I get this output:
Warning: calling DestroyWindow in CWnd::~CWnd; OnDestroy or PostNcDestroy in derived class will not be called.
Warning: m_pMainWnd is NULL in CWinApp::Run - quitting application.
The thread 'Win32 Thread' (0x914) has exited with code 0 (0x0).
The program '[6628] VentSizerPro.exe: Native' has exited with code 0 (0x0).
So somewhere along the line m_pMainWnd has been changed to NULL, but where and why and how and what? :(
EDIT:
m_Frame is an instance of a class that exends CFrameWnd to modify the window frame.
Don't be an idiot.. you assigned the pointer value to the value of a local variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With