Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Problem with modeless dialog creation

tgsaudtgsaud Member Posts: 5
I have an application that runs various tests on my system, and I have a main menu that comes up and allows you to select the test you want to run. Each of the tests has its own dialog, and when they are run, they are run as modal dialogs. I wanted to create a new test that consolidates several of the existing tests. My plan was to open the dialogs I need as modeless dialogs, set the parameters I need, and then force the test to start, having my modal dialog monitor the test as it is running in the other dialog (I would not even need to have the other dialog visible). I did not want to have to duplicate the code in my new, consolidated test.

In my new test's dialog window object, I added:
classPtr = new className(this);
bSuccess = classPtr->Create(className::IDD, this);

I have two problems when I do this.

1. Even though the new test dialog is derived from CDialog, when I do the classPtr->Create(className::IDD, this), I get an assertion failure. Debugging shows the problem is that "this" is not a valid CWnd object.

2. I changed "this" above to either NULL or CWnd::GetDesktopWindow(), and this appears to work, except that the newly created window seems to lock up. I did classPtr->ShowWindow(SW_NORMAL) to see what it was doing, and it shows my dialog I am trying to open, but it is completely blank. I put a Sleep(10000) in after the ShowWindow(), and then popped up a message box after the 10 seconds, and as soon as the message box popped up, the classPtr window refreshed and was accessible. When I closed the message box, the classPtr window locked up again.

Any idea what is happening here, and how to fix it.

I am assuming that since my new test dialog is modal, and the parent window is the application window (if NULL), the modal window prevents the modeless window from running because it preempts the parent window. I tried making my test a modeless window as well, but problem #2 above still happened.

Any assistance would be appreciated.

Sign In or Register to comment.