Microsoft HomeProductsSearchSupportShopWrite UsMicrosoft Home
Microsoft Technical Support
Microsoft Technical Support


Search Support Online: Search the entire collection of articles and self-help tools.
Frequently Asked Questions: Read answers to the most commonly asked questions.
Glossary: Learn computer terms and abbreviations used throughout Support Online.
Submit a Question: Submit a technical question to one of our Support Engineers.

How to Use Visual Test 4.0 with Painted Controls

Last reviewed: September 7, 1995
Article ID: Q136207
The information in this article applies to:
  • Microsoft Visual Test for Windows 95 and Windows NT, version 4.0

SUMMARY

Microsoft 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 INFORMATION

Applications 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 Control

You 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:

  1. Start Word 95 or Microsoft Word version 6.0.

  2. On the Edit menu, click Find to bring up the Find dialog box.

  3. Then use Winfo to try to select the FindNext button. You will realize that you are unable to do so. This is because that button is not a true control; it is a painted control. Therefore, you will not be able to use WButtonClick "FindNext" to click the painted control from a Visual Test Script. Nor will you be able or interact with that control using any WButtonxxxxx Functions. You need to use the Play or WClkWnd commands to click the painted control.

Using the Scenario Recorder

You 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.

REFERENCES

For more information on this topic, please see the following Visual Test Help topics:

  • Window Information Utility
  • Scenario Recorder
  • Play

Did this information help answer your question?
 Yes  
 No
 It didn't apply  


Additional reference words: 4.00 Win32
KBCategory: kbprg kbcode
KBSubCategory:


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 7, 1995
©1997 Microsoft Corporation. All rights reserved. Legal Notices.