views:

19

answers:

2

In my application, I have a component, which opens a pop-up window (save dialog). There's no legitimate method for disabling that dialog. Killing it by timer is not reliable way. Is there any accurate way for preventing the dialog from opening?

A: 

Perhaps some WndProc and WM_CHILDACTIVATE love. (Of course I am assuming said dialog will trigger this.) You may need to jump directly into the Win32 WndProc API -- see SetWindowLong -- if you need to replace an existing (but same process) or application-level message pump.

YMMV. Have fun.

pst
A: 

This smells pretty bad. Why is one part of your application trying to hamper another part? If the component that's opening a dialog isn't a user facing component and you're trying to strangle the pop-up in the UI then you need a bit of rework to ensure that the component notifies the UI of it's need for a file name and the UI can choose how to get it. If you're using an component internally and it annoyingly opens a dialog then it sounds like you need to tweak that component so that the dialog depends on it being used by a user not a service.

Like most winapi problems there will be a way to hack it in, monitoring your applications focus, catching the WM_CHILDACTIVATE or polling the top level window might all work but they're all hacks to get around the fact that your application isn't consistent in it's design. If you can fix the design you'll end up with a more reliable solution that your co-workers won't cringe at.

Daniel