Sensing a Modal Dialog Box

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

I have an application that is automating Project Professional; when opening
certain projects, I receive a modal dialog box. As long as I can simulate
the clicking of the cancel button, I could programmatically move past it.
How can I do this?
Note: while opening Project Server, I already set the alerts to false. This
dialog comes up anyway (but all of the others are closes).
 
* "Dan said:
I have an application that is automating Project Professional; when opening
certain projects, I receive a modal dialog box. As long as I can simulate
the clicking of the cancel button, I could programmatically move past it.
How can I do this?

I am not sure what 'Project Professional' is (are you talking about MS
Project)?
 
Yes, MS Project Professional. My issue is not about project, though; it is
about sensing a dialog box.
 
* "Dan said:
Yes, MS Project Professional. My issue is not about project, though; it is
about sensing a dialog box.

You can try to send an escape using 'SendKeys.Send' (but this is not
recommended).
 
I have done this with dialog boxes on other applications. The method I use is not a particulalry 'nice' way of removing a dialog box but it does work. I'm not sure if there is a clean way to do it with the .NET Framework classes but I have done it by simply using API's (mainly due to the fact that I still use the same code which I ported from my old VB6 apps). The first thing you need to do is to find out the Class Name (internal registered windows name for the window) and also Window Title are of the particular dialog box. The window title is simple as it is shown on the dialog but in order to find out the class name you will need to use Spy++ which is one of the tools that comes with VS.NET

Once you know the name and class of the window, you use the FindWindow API to get a handle to the dialog window. Once you have this handle, you can then use the GetWindow API in conjunction with the GW_CHILD and GW_HWNDNEXT flags to itterate through the child windows of the dialog window until you find the child window which is the 'OK' button. Once you have a handle to this button, you can then simply use the SendMessage API to send a BM_CLICK message to the button which will press it and clear the dialog

Gary
 
Back
Top