Trapping non VB windows opening/closing
-
I have a problem in that I have created a Web browser control in a VB application. This then calls various ASP web pages. Within one of these web pages a Twain component is loaded to drive an Epsom scanner. Once the scan has completed then the dialog window opened by the Twain component closes down and the windows underneath redrawn. However if you click on the close button on the Twain dialog instead, then the dialog seems to be closed down initially, but then gets re-displayed but only with the outline of the Twain dialog showing (no content is displayed and I just get a grey filled in area), covering most of the underlying browser. I obviously need to trap when the window is closed down, but I am not sure how to do this, as the supplier of the component has stated that they don't create a close event for the Twain dialog, and that it should be done through a Windows API call. But I will not know the handle of the window, and I don't want to continuously refresh the screen just to try and clear the display if someone clicks on the close button. If the web pages are displayed on their own using IE 5 and then you click on the close button then the Twain dialog gets cleared correctly. Can anyone help me out here. Thanks. Simes
-
I have a problem in that I have created a Web browser control in a VB application. This then calls various ASP web pages. Within one of these web pages a Twain component is loaded to drive an Epsom scanner. Once the scan has completed then the dialog window opened by the Twain component closes down and the windows underneath redrawn. However if you click on the close button on the Twain dialog instead, then the dialog seems to be closed down initially, but then gets re-displayed but only with the outline of the Twain dialog showing (no content is displayed and I just get a grey filled in area), covering most of the underlying browser. I obviously need to trap when the window is closed down, but I am not sure how to do this, as the supplier of the component has stated that they don't create a close event for the Twain dialog, and that it should be done through a Windows API call. But I will not know the handle of the window, and I don't want to continuously refresh the screen just to try and clear the display if someone clicks on the close button. If the web pages are displayed on their own using IE 5 and then you click on the close button then the Twain dialog gets cleared correctly. Can anyone help me out here. Thanks. Simes
Hey Simes, It's been a while since I did something like this, but I would use the windows spy utility which lets you point at open windows and get identifying properties from them. You can find the window class for this dialog box which popups then use that class to find it again in your own program. You would have to sit in a loop watching for this window to close, i.e. you are no longer able to find it. I would also Sleep in that loop so you don't check for the close millions of times, just a couple of times a second. If you look around for code that uses FindWindow or refer to the stuff I have pasted below for you, you should be a good way to your solution. Its a pretty good tutorial on using Findwindow. It's targeted at Microsoft Access VBA, but I'm sure you understand that this would work in VB. Hope this is of some help. PSS ID Number: Q210605 Article Last Modified on 05-16-2002 -------------------------------------------------------------------------------- The information in this article applies to: Microsoft Access 2000 Microsoft Visual Basic for Applications -------------------------------------------------------------------------------- Advanced: Requires expert coding, interoperability, and multiuser skills. This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp). Summary Through the use of a Windows application programming interface (API) function, Microsoft Access can determine if another program is already running. There may be times when you want only one instance of an application to run in Microsoft Windows. For example, if you add a command button to a form that starts the Windows Calculator (Calc.exe) program, you can start many instances of Calculator. This is an inefficient use of memory and system resources. The API function used to determine whether a specific program is running is called FindWindow(). FindWindow() returns the handle of the window whose class is given by the lpClassName parameter and whose window name (or caption) is given by the lpCaption parameter. If the returned value is zero, the application is not running. Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft su
-
I have a problem in that I have created a Web browser control in a VB application. This then calls various ASP web pages. Within one of these web pages a Twain component is loaded to drive an Epsom scanner. Once the scan has completed then the dialog window opened by the Twain component closes down and the windows underneath redrawn. However if you click on the close button on the Twain dialog instead, then the dialog seems to be closed down initially, but then gets re-displayed but only with the outline of the Twain dialog showing (no content is displayed and I just get a grey filled in area), covering most of the underlying browser. I obviously need to trap when the window is closed down, but I am not sure how to do this, as the supplier of the component has stated that they don't create a close event for the Twain dialog, and that it should be done through a Windows API call. But I will not know the handle of the window, and I don't want to continuously refresh the screen just to try and clear the display if someone clicks on the close button. If the web pages are displayed on their own using IE 5 and then you click on the close button then the Twain dialog gets cleared correctly. Can anyone help me out here. Thanks. Simes
Hey Simes, It's been a while since I did something like this, but I would use the windows spy utility which lets you point at open windows and get identifying properties from them. You can find the window class for this dialog box which popups then use that class to find it again in your own program. You would have to sit in a loop watching for this window to close, i.e. you are no longer able to find it. I would also Sleep in that loop so you don't check for the close millions of times, just a couple of times a second. If you look around for code that uses FindWindow or refer to the stuff I have pasted below for you, you should be a good way to your solution. Its a pretty good tutorial on using Findwindow. It's targeted at Microsoft Access VBA, but I'm sure you understand that this would work in VB. If you need more help, please dont hesitate to shout me. Hope this is of some help. PSS ID Number: Q210605 Article Last Modified on 05-16-2002 -------------------------------------------------------------------------------- The information in this article applies to: Microsoft Access 2000 Microsoft Visual Basic for Applications -------------------------------------------------------------------------------- Advanced: Requires expert coding, interoperability, and multiuser skills. This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp). Summary Through the use of a Windows application programming interface (API) function, Microsoft Access can determine if another program is already running. There may be times when you want only one instance of an application to run in Microsoft Windows. For example, if you add a command button to a form that starts the Windows Calculator (Calc.exe) program, you can start many instances of Calculator. This is an inefficient use of memory and system resources. The API function used to determine whether a specific program is running is called FindWindow(). FindWindow() returns the handle of the window whose class is given by the lpClassName parameter and whose window name (or caption) is given by the lpCaption parameter. If the returned value is zero, the application is not running. Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and