Discussion:
ActiveX Control with modal dialog does not work in IE 7
(too old to reply)
royHe
2007-08-24 17:40:07 UTC
Permalink
ActiveX Control with modal dialog does not work in IE 7. The modal dialog is
hidden behind the main browser windows and prevent user from continuing
interacting with the control. User has to use "End Task" to close the
windows.

It has been work in the IE6 browser, although the modal dialog is also
hidden some time, but very rare.

Thank you for your help in Advance.

Roy
Sheng Jiang[MVP]
2007-08-27 18:33:37 UTC
Permalink
I suggest you change your dialog's owner, or start your modal dialog in
another thread. This also applies to a menu popup, since menu popup creates
a modal loop as well.

A modal UI disable its owner while the modal UI is being displayed. Since
the Windows implementation of COM is relying on its message pump to
function, disable the container window and run another message pump dictated
by an ActiveX control blockes the COM container's access to messages until
the modal dialog is dismissed. This introduced so many bugs in IE that
nested message loops are disabled in WPF. While modal UI is not suggested in
Activex, blocking an IE window in IE 6 does not cause a lot of problem
because each IE window has a seperate thread.

The change in IE7 is that the main window is no longer in the same thread of
the ActiveX, while each tab has a seperate thread and hosts ActiveX controls
in that thread. If you display a modal UI using the main window, the
foreground window, or the window returned by IWebBrowser2::get_hwnd as the
owner window, you will block the main application that hosts all tabs.
Instead, you should try to use the window of the tab displaying your hosting
webpage as the owner window of your modal interface to get the window handle
of the hosting tab, do the following:

1 In your activex's IOleObject::SetClientSite implementation, QI
IServiceProvider from the client site
2 QS the SID_STopLevelBrowser service and QI IServiceProvider (your ActiveX
might 3 reside in a frame, so ask the top level browser just in case)
QS the top level browser for the SID_SShellBrowser service and QI for
IOleWindow
use IOleWindow::hwnd to get the window handle of the IE tab

when you need to display a modal UI, you need to use the window handler of
the IE tab like this
MessageBox(hwndIETab, _T("Foo"), _T("Bar"),MB_OK);
Reference
Modality, part 5: Setting the correct owner for modal UI
http://blogs.msdn.com/oldnewthing/archive/2005/02/24/379635.aspx
FIX: A Visual Basic 6.0 modal form is no longer modal when the form is
displayed from a user control in Internet Explorer 7
http://support.microsoft.com/kb/930828
BUG: Office repaint problem if modal form is shown from ActiveX EXE
http://support.microsoft.com/kb/242017
Nested message loops are evil
http://blogs.msdn.com/nickkramer/archive/2006/05/06/591252.aspx
Apartments and Pumping in the CLR
http://blogs.msdn.com/cbrumme/archive/2004/02/02/66219.aspx
INFO: OLE Threads Must Dispatch Messages
http://support.microsoft.com/kb/q136885/
--
Sheng Jiang
Microsoft MVP in VC++
Post by royHe
ActiveX Control with modal dialog does not work in IE 7. The modal dialog is
hidden behind the main browser windows and prevent user from continuing
interacting with the control. User has to use "End Task" to close the
windows.
It has been work in the IE6 browser, although the modal dialog is also
hidden some time, but very rare.
Thank you for your help in Advance.
Roy
Continue reading on narkive:
Search results for 'ActiveX Control with modal dialog does not work in IE 7' (Questions and Answers)
11
replies
What is Internet Explorer ?Give answer in detail.?
started 2006-10-09 08:45:34 UTC
computers & internet
Loading...