WebBrowser Control to detect type of loaded document

I have the following problem. My C++ application creates WebBrowser Control object (CLSID_GFWebBrowser) and displays and URL there. The URL is to an authorization form (enter user name and password). When username/password are invalid, the response will be HTML page with message like invalid username or password. When the authorization passed, the response will be not-HTML document (PDF, DOC, XLS, PPT).

My application has to recognize the not-HTML response and close the browser window immediately. The problem is: how to recognize it? I tried to handle event DWebBrowserEvents2::DownloadComplete, but in this moment we cannot understand what the document type is. It will be possible later, when event DWebBrowserEvents2::DocumentComplete happens. But when the document is MS Offices (DOC, for instance), the dialog with Open, Save or Cancel? will appear first I do not need this. I tries to suppress the dialog appearance, but could not.
[953 byte] By [KellyLynch] at [2007-11-20 1:36:14]