tags:

views:

512

answers:

2

I'm having problems with some code to create a CDialog based window. The code was working fine last week. The only changes I made was replacing a C++ deque with a hash array. I had commented out the line of code with the Create method being called to allow me to skip loading the window. Now the code doesn't create the window at all anymore.

The Create function returns false and the GetLastError function returns 0. I don't use any custome controls inside the window - just a checkbox and a list control. As far as I can tell (I can't hook a debugger up at this point) the OnCreate and OnInitDialog functions are not being called at all.

I've pasted the code below that I've been using to test the Create function's return 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: I finally managed to get the debugger to attach (this is a plugin loaded in a 3rd party application that didn't like the debugger for some reason). After stepping through the code it seems that AfxGetMainWnd() is returning NULL. I'm doing more testing on this now.

A: 

Does the dialog use any controls that might be causing the problem? A richedit for example?

Rob
No, there's just a checkbox and a list control. I've even tried removing all of the controls and commenting out the respective code in the class and still can't get Create() to work.
Noaki
A: 

The problems seems to have been with the call to CDynLinkLibrary().

I had commented this out at the request of the company that writes the software that is loading my plugin. Adding this line back in caused some values to still be null, but the window is now created properly.

I'm going to do a bit of research on this and will update if I find anything. If anyone knows more about this than me (not hard to do) feel free to leave comments.

Noaki