Microsoft Knowledge Base |
|
How to Use ScnCaptureWindow & ScnCompFile in Microsoft Test |
|
|
Last reviewed: July 25, 1996
Article ID: Q136081 |
|
The information in this article applies to:
SUMMARYIt is often useful when testing to compare and contrast a window's visual appearance (bitmap) at various stages of a product's development. TestBasic offers a family of functions prefixed with Scn that provide the functionality necessary for such a test. The functions ScnCaptureWindow and ScnCompFile are demonstrated in this article. More information on Scn* functions and statements is available through the Help menu.
MORE INFORMATIONWhile testing a window's appearance, you need to determine if the window has been altered by development, operating system variables, or logic errors in the construction of the test code. This article will:
Why a Window's Appearance May VaryThe following is a list of variables that will alter a window's appearance that are not development related. Most windows contain child windows and/or controls. Most child windows or controls indicate to a user that they have input focus by altering their appearance. For example: a command button draws a dotted rectangle around its caption, a child window's borders take on the active window border color. An MDI parent window alters its title bar content (caption) depending on whether or not a child window is maximized. A change in video resolution will cause a window to look different.
How to Minimize the Chance of Varying Window AppearanceThe sample function CaptureCompWindow demonstrates a technique that minimizes the chance of non-development related variables affecting a window's appearance. Copy the following code into a new window and save it as UsefulTools.inc:
Declare Function CaptureCompWindow _
(fCapture As Integer, strFileName As String, _
strImageName As String, hwnd As Long, fHide As Integer, _
fCheckLoc As Integer) As Integer
Function CaptureCompWindow _
(fCapture As Integer, strFileName As String, _
strImageName As String, hwnd As Long, fHide As Integer, _
fCheckLoc As Integer) As Integer
Dim strImageNameOrg As String
' The image name is suffixed with '[Original]' for ease of
identification,
' and will be used in later comparisons.
strImageNameOrg = strImageName + " [Original]"
If fCapture Then
' This logical flow is followed only when making an original or
' over-writing the original.
ScnCaptureWindow( strFileName, strImageNameOrg, hwnd, fHide )
Else
' The image name is suffixed with a date/time stamp for ease of
' identifying the new image and documenting when the image was
' created.
Dim strImageNameNew As String
strImageNameNew = strImageName + " [" + DateTime$ + "]"
' The new image is saved to the same file,
' but uses the new image name.
ScnCaptureWindow( strFileName, strImageNameNew, hwnd, fHide )
' The comparison is performed on the original and
' new images from the file.
' This allows the tester to view what made the images vary at a
' later time using 'Screen Utility.'
If ScnCompFiles( strFileName, strImageNameOrg, strFileName, _
strImageNameNew, fCheckLoc ) Then
' The images vary--report it to the ViewPort.
Print "CaptureCompWindow Error: '" + strImageNameNew + _
"' varies from original."
' Return False
CaptureCompWindow = False
Exit Function
End If
End If
' Everything went fine return True.
CaptureCompWindow = True
End Function
What CaptureCompWindow DoesThe CaptureCompWindow function benefits a tester by allowing a capture or comparison to be performed at the same point in a TestBasic script. This minimizes the chance that the window being tested varies in state at the time of capture and the time of comparison. CaptureCompWindow documents, to the ViewPort, an unsuccessful comparison of the new image to the original image. Also, CaptureCompWindow saves the original and new image to the same screen file for later viewing.
Step-by-Step Sample Using CaptureCompWindowThis procedure makes use of the Visual Test tool called Screen Utility. Books Online documents the Screen Utility under "Visual Test Utilities User's Guide."
|
|
Additional reference words: 4.00 Win32
©1997 Microsoft Corporation. All rights reserved. Legal Notices. |