MFC CDialog :: Create Crash
I am having problems with some code for creating a CDialog based window. The code worked fine last week. The only changes I made was to replace the C ++ deque with an array of hashes. I commented out the line of code when calling the Create method to allow me to skip loading the window. Now the code no longer creates the window.
The Create function returns false and the GetLastError function returns 0. I am not using any custome controls inside the window - just a checkbox and a list control. As far as I can tell (at the moment I cannot connect a debugger) the OnCreate and OnInitDialog functions are not called at all.
I pasted the code below which I used to check the return of the Create function and GetLastError
BOOL result = ORDER_HANDLER_GUI.Create(OrderHandlerGUI::IDD, AfxGetMainWnd());
int error = ::GetLastError();
if(result)
AfxMessageBox("Created GUI");
else
{
CString msg;
msg.Format("%d", error);
AfxMessageBox("Could not create GUI");
AfxMessageBox(msg);
}
Update: Finally, I was able to connect the debugger (this is a plugin loaded in a third party application that the debugger didn't like for some reason). After stepping through the code, it seems that AfxGetMainWnd () returns NULL. I am doing more tests now.
a source to share
The problems seemed to be related to the CDynLinkLibrary () call.
I commented on this at the request of the company that writes the software that downloads my plugin. Adding this line back resulted in some of the values still being blank, but the window is now correctly created.
I'm going to do a little work on this and update if I find anything. If anyone knows more about this than me (not hard to do), feel free to leave comments.
a source to share