Simulate halting of processing of a modal window in dhtml?

monkeydust

New member
We have been experimenting with creating dhtml popup windows to replace modal dialog windows in our application (showModalDialog) since they can look nicer. One thing that I haven't gotten around is reproducing how modal dialog windows would stop the execution of code in the parent window until the modal window was closed. Sure, we can restructure a ton our code and set callback functions in the dhtml popups. But, we'd rather not have to do that.

Note, this is only for code processing that I am having an issue with. For example, I hit line 1 and then line 2 opens the dhtml "modal" window and line 3 would not process until we close the window (dhtml div) displayed on line 2. This is all done in javascript by the way.

Any way to accomplish this other than callback functions?
 
This is not as easy as it sounds. The code doesn't actually halt when you display a modal dialog. It can't or your user interface would become non-responsive. Instead, the code goes into a Windows Message loop. The message loop is reading, and routing any windows messages that are received by the current window. (The dialog). I have, on a Windows desktop application, used the Win32 API to create my own message loop to perform the same function as a modal dialog display. But, I don't think there is any way to do such code in a DHTML script without creating an ActiveX control that implements the message loop.
 
Yeah, I tried simulating it by buiding my own loop but of course that didn't work because it popped up a message asking if you want to continue running the script as it may become unresponsive.

I guess we are just going to have to restructure a bunch of our code since we have sprinkled modal windows throughout it that stops execution until a response is returned.
 
Yeah, I tried simulating it by buiding my own loop but of course that didn't work because it popped up a message asking if you want to continue running the script as it may become unresponsive.

I guess we are just going to have to restructure a bunch of our code since we have sprinkled modal windows throughout it that stops execution until a response is returned.

It's a big pain if you have any exception handling because now every event handler needs to catch your exceptions. The best thing you can do is try and minimize the interface between your client and the dialog. Raise as few events as possible and have the dialog handle it's own validation and such.
 
Back
Top