I am debugging a strange issue with a 3rd party library that displays a formatted message box. The library uses a class based on CDialog and runs the message box dialog with the DoModal() method. Sometimes a message is displayed from a common subroutine that uses the handle of the main window as the parent (type 1), other times from another modal dialog (type 2).
Sometimes a Type 1 call is triggered by an action in a modal dialog and when this happens, the original dialog is no longer modal after the message dialog is dismissed. Changing nothing except the formatted message box with the system default message box and the original dialog stays modal, as expected. When a Type 2 call is made, the original dialog always remains modal, so I am working to ensure that is how I call the library function, but this looks like it might be a bug in the CDialog itself, so I thought I would ask if anyone knows about this.
I have never worked with these class libraries before (I'm an old school C guy), but it looks like the library is always using EndDialog() to terminate the modal message box and there's no "fancy, low-level" windows stuff that I can find (other than the message formatting). It is probably obvious that I don't really know what I'm asking, so if there is a better place to discuss this, please send me there.
On the other hand, if anything derived from CDialog and DoModal() does this, it would appear to be a bug in the class library, since built-in modal dialogs (like MessageBox) do not have this unwanted effect. I would share the library code, but I am not the original author and I don't have permission, but I am willing to look for things as long as you are willing to have some patience for someone not familiar with C++ code structuring.
CDialogclass, notCDialogEx? The latter has some issues. Also it's difficult to follow your question without any source code. - Barmak Shemiraniclass MessageBoxEx : public CDialogso, as I understand it, the class is based onCDialog, right? Sorry about code, I have no idea what specific snippets to post and I don't own it, so I cannot simply share large blocks. - Steve ValliereEndDialogis the low-level Windows API call to close a modal dialog. - IInspectableEndDialogis correct, but I don't know what additional things theCDialogclass might be doing behind the scenes. Apparently, it is different from whatMessageBox(or any "standard" modal dialog) does. I worked around the problem by finding a way for the shared functions that pop messages to always use the active modal window handle or main window handle, as appropriate, but I should not need to do that. Oh well, I don't think there will ever be an answer to this. Thanks to all for considering it, though. - Steve VallierepParentWndparameters have default values. If you don't pass a parent (which is really an owner), MFC will go looking for an appropriate owner window. It would certainly help to see a minimal reproducible example to provide directed help. - IInspectable