Closing dialog boxes programmatically

contains all delphi packages mentioned below
Post Reply
GuyWithDogs
Posts: 2
Joined: Sun Oct 10, 2004 4:21 am

Closing dialog boxes programmatically

Post by GuyWithDogs »

I've written a program that uses TWebBrowser to implement a display for web-based content. However, there are cases where some web sites, or Windows itself, will pop dialog boxes up during my presentation playback.

I was looking into ways of automatically detecting when this happens (a new dialog is created), and of having a program do the following:

1. Detect that the new window/dialog has been created
2. Determine which dialog is present
3. Based on the dialog, close or terminate the dialog

Detecting what's there is important, since I don't want a generic "click OK" routine to say "Sure, download Gator" or other things, or accidentally agree to take part in Microsoft's survey on how their web site works.

Based on all this, I ran across "system hooks", and since I'm using Delphi 7 and targetting Windows 2000 and Windows XP only, I ended up finding out about the mad* products.

Will these help me do what I want? Is what I want possible?

Thanks.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

You could use SetWindowsHookEx(WH_CBT) to hook window creation. You don't need my components for this purpose.

Alternatively you could e.g. hook the MessageBox API by using my madCodeHook package.

It's hard to say for me which is the better approach. Do you know which API(s) the IE uses to pop up those dialog windows you want to control? If you know the exact API then using madCodeHook would eventually be the easier way to control the popup dialogs. If you don't know the API IE uses and if you're not able to find that out, then probably SetWindowsHookEx should be your first choice.
GuyWithDogs
Posts: 2
Joined: Sun Oct 10, 2004 4:21 am

Post by GuyWithDogs »

Thanks for the information. I don't know what the API call is (yet), but I'm also worried about other (evil) dialog boxes that appear. I've had the "you're out of virtual memory ... buy some more" pop up at a few points. That's definitely one I want to quash, since I'm never sure when that one will appear.

I'll look more into that call you mentioned.
Post Reply