Microsoft Knowledge Base |
|
How To Manipulate the ScrollBars on a Window |
|
|
Last reviewed: January 10, 1997
Article ID: Q156763 |
|
The information in this article applies to:
SUMMARYA window can contain either "Window ScrollBars" or "ScrollBar Controls." Visual Test provides the "WScrollBar..." functions in order to manipulate the "ScrollBar Controls." You can use the Windows API Functions to manipulate Window ScrollBars. You can use the Winfo Utility to distinguish between the two types of ScrollBars.
Scrollbar ControlsYou will be able to select (highlight) these controls using the Winfo Utility. Useful information such as the ordinal value can be retrieved by Winfo. Once retrieved, these values can be used in the functions provided by Visual Test to manipulate the Scrollbar Controls. A good example is the use of the ordinal value retrieved by Winfo in the WScrollBar... Functions like WScrollSetPos():
WScrollSetPos ( "@1", 100)The Write program provided by Windows NT 3.51 is an example of an application that uses ScrollBar Controls.
Window ScrollbarsAnother type of ScrollBar is the Window ScrollBar that is generated from setting a style within a newly-created window to enable it to contain a scrollbar. Window ScrollBars are not stand-alone controls. Rather, they are physically part of the window. Because they are not individual controls, you will not be able to use the Visual Test WScrollBar... Functions to manipulate them. Window Scrollbars cannot be selected using the Winfo Utility. The Notepad program provided by Windows 95 is an example of an application that uses Window ScrollBars. To manipulate Window Scrollbars directly from Visual Test, you must use Windows API functions to interact with the Window ScrollBars. This article shows you how to do this.
MORE INFORMATION
Using Windows API's to Manipulate ScrollbarsThe following steps detail the process of creating a Test language script that will manipulate scrollbars within Notepad. This example will start the Windows Notepad (NOTEPAD.EXE) application, load a Text file, and scroll halfway down the document:
WMenuSelect("&File\&Open...")
CurrentWindow = WFndWndC("Open", "#32770", FW_FOCUS OR FW_PART, Timeout)
sleep 3
'Setting the file name
WEditsettext("File Name:",FileName)
WButtonclick("Open")
hWPad = WFndWndC("Notepad", "Notepad",FW_PART or FW_FOCUS , Timeout)
hWedit = WFndWndC(_ord(1) ,"edit" ,FW_PART or FW_FOCUS ,timeout)
'Get the minimum/maximum range value that you can set to
'scroll the window
GetScrollRange hWedit , SB_VERT ,Varptr(xcord) , Varptr(ycord)
' You can set some valid position value
' You are using half of the Maximum scroll range
lpvalue =mklng(SB_THUMBPOSITION,Ycord\2)
T = "Note that Notepad displays the top Page"
StatusBox T, 1, 1,300,30,true,, "MS Sans Serif", 12, 900
sleep 3
'This sends a message to the parent window of the scrollbar
Ret = SendMessage(hwedit ,WM_VSCROLL,lpvalue ,NULL)
T = "Check to see if the Page in Notepad is Scrolled down"
StatusBox T, 1, 1,300,30,true,, "MS Sans Serif", 12, 900
sleep 3
T = "Closing Notepad"
StatusBox T, 1, 1,300,30,true,, "MS Sans Serif", 12, 900
sleep 2
StatusBox close
'Closing Notepad and ending the Script
CurrentWindow = WFndWndC("Notepad", "Notepad", FINDWINDOWFLAGS, Timeout)
WMenuSelect("&File\Exit")
End
REFEENCESThe sample code listed above uses the following Win32 API functions:
GetWindowsDirectory() , SendMessage().For more information concerning these functions, please refer to the Win32 SDK Help files. For more information on using the Winfo Utility, please refer to the Visual Test Online Help under:
Visual Test 4.0 Books Online
\ Utilities User's Guide
\ Window Information Utility
|
|
KBCategory: kbusage kbhowto
©1997 Microsoft Corporation. All rights reserved. Legal Notices. |