![]() ![]() ![]() ![]() ![]() ![]() | ![]() | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
How to Use Visual Test 4.0 with Painted ControlsLast reviewed: September 7, 1995Article ID: Q136207 |
The information in this article applies to:
SUMMARYMicrosoft Test has functions you can use to interact with standard controls that are generally used by the Windows-based applications you are testing. The standard controls have class names like Edit, Button, Static, ComboBox, ListBox, or ScrollBar. Microsoft Windows-based applications can also have control-like drawn or painted objects. This article discusses some of the issues related to using Visual Test to interact with such objects.
MORE INFORMATIONApplications may not always use standard or custom windows controls for various reasons such as saving resources and gaining speed. The standard controls have an underlying procedure to handle the user-triggered events such as the Click event. For example, in a Microsoft Visual Test script, the WButtonClk function sends a message to the button control to tell the button that it was clicked so it needs to run the Click event procedure to process that message. A painted control is really not a control at all. It doesn't have a class name or any other characteristics of a window. Even though it looks like a control (for example, it might look like a button) and behaves like a control, you can't send a Windows message to it because it is not a true control and does not have the underlying event procedure to handle it. The application's dialog box or window that has this painted object will process the message. If you use the WButtonClick function, the message is not going anywhere, so the function will fail. Therefore, painted controls must be handled in a different way. You can use the Play or WClkWnd functions to interact with painted controls to some extent. Programs such as Microsoft FoxPro, Microsoft Access, and Microsoft Word use a lot of these control-like objects known as painted controls.
How to Determine the Type of a ControlYou can determine the type of a control in many different ways. You can use the Window Information Utility that comes with Microsoft Test to find the class name of the control of a window. On the Test menu, click WInfo in Microsoft Visual Test to run this utility. For more information on using the WInfo utility please refer to the "Window Information Utility" topic in the Help menu. If you drag the WInfo icon onto the control, a true control will become highlighted and the tool will display the characteristics of the control - such as the handle, the class name, the ID, and so on. If it is not a true control, it will not become highlighted; that is, you will not be able to select the control at all. For Example, Microsoft Word and Word 95 have a Find dialog box that contains a number of painted controls. Follow these steps to see them:
Using the Scenario RecorderYou can use the Scenario Recorder to get an idea about the Commands you need to use to search for a word such as "book" by using the Find dialog box in Microsoft Word 95 or Word version 6.0. The following is a sample Scenario recorded using the Scenario Recorder Utility that comes with Visual Test version 4.0. Some comments have been manually added for clarity.
'$INCLUDE 'RECORDER.INC'SetDefaultWaitTimeout(Timeout) Scenario "test" 'Minimize the Visual Test window. If GetHandle(GH_HWNDCLIENT) Then WMinWnd(GetHandle(GH_HWNDCLIENT)) ' Check the resolution that this script was recorded on. CheckResolution (800, 600) ' Find MS Word CurrentWindow = WFndWndC("Microsoft Word", "OpusApp", _ FINDWINDOWFLAGS, Timeout) 'Select the Edit - Find Menu WMenuSelect("&Edit\&Find...") ' Find the Dialog ' Note that if you are using Word 95, the class name is ' bosa_sdm_Microsoft Word for Windows 95 CurrentWindow = WFndWndWaitC("Find", "bosa_sdm_Microsoft Word 6.0", _ FINDWINDOWFLAGS, Timeout) 'Position the dialog box WSetWndPosSiz(CurrentWindow, 295, 23, 481, 201) Sleep(3.565) Play "book" 'Move to the next field to select all Play "{TAB}" Play "all" 'The following command clicks the FindNext button Play "{Click 692, 61, Left}" 'The following command clicks the Cancel Button Play "{Click 718, 90, Left}"End Scenario Notice that this code doesn't use the WButtonClick function to click the buttons. Instead it uses the Play command, and it is important that the Find dialog box remain at a particular position for the Play command to work. This is achieved by the using WFndWndWaitC and WSetWndPosSiz in the lines just above the Play commands. Also notice that the "All" from the combobox-like control is selected by using "Play "{TAB}"" and "Play "All"" instead of using the WComboItemClk function.
REFERENCESFor more information on this topic, please see the following Visual Test Help topics:
|
Additional reference words: 4.00 Win32
©1997 Microsoft Corporation. All rights reserved. Legal Notices. |