Creating multiple MFC dialogs through COM, strange behaviour

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-04-28T12:30:22Z Indexed on 2010/04/28 12:33 UTC
Read the original article Hit count: 356

Filed under:
|
|
|

One of our apps has a COM interface which will launch a dialog, e.g:

STDMETHODIMP CSomeClass::LaunchDialog(BSTR TextToDisplay)
{
  CDialog *pDlg = new CSomeDialog(TextToDisplay);
  pDlg->BringWindowToTop();
}

For some reason when the COM method is called several times at once by the server, we get odd behaviour:

  • We get multiple dialogs, but only one entry in the taskbar
  • Dialog Z-order is based on order created and can't be changed... the first dialog created is always shown under the 2nd one, 2nd under 3rd, etc, even when you drag them around
  • if N dialogs were created, closing one of them closes it and all the others created afterwards. e.g if 5 dialogsa re created and you close the 3rd one, #3,#4,#5 all get closed.

It's somehow like the dialogs are siblings but I don't see anything weird going on. Is it perhaps due to COM, or is this a weird MFC/Win32 issue?

© Stack Overflow or respective owner

Related posts about mfc

Related posts about win32