We had some weird crashes in our client application and I finally reproduced it in a wizard generated 3-liner:
This "works" in VC6 and VC7.
Create a Dialog based MFC Application. Deselect all features. When your Dialog comes up, double click the OK Button. This will send you directly into the code. You just overwrote OnOK. Now make it look like this, opening up another copy of the same dialog:
While obviously stupid, it will show what my problem is. Start the program. Click OK. Move the dialog a bit. Click OK on the new Dialog again. You now have three windows, each one modally bound to it's parent. Click with the mouse on each one, only the topmost window ( the last in the modally opened chain ) will activate.Code:void CCDialogTestDlg::OnOK() { CCDialogTestDlg dlg; dlg.DoModal(); }
So far, it's working as intended.
Now select the middle/second window in the chain in the taskbar. Voila, the second window is selected and ready for input by keyboard ( not usable with the mouse though ).
You can probably imagine that working with and closing the second window in a three ( or more, test it ) dialog chain will crash any application. I cannot have a user select which dialog he wants to answer to, that's what modal dialogs are for: topmost first. Nothing else.
I tested this in VC6, then hoped it was a bug and tested it in VC7 resulting in the exact same behaviour. So I guess it must be me being totally confused and unable to set the right flag when creating a dialog. Does anyone have any ideas how to solve this ?