HOWTO: Extend the Scrolling Capabilities of a TextBox ControlLast reviewed: July 15, 1997Article ID: Q161270 |
The information in this article applies to:
SUMMARYUsing the Windows API function SendMessage, you can scroll text a specified number of lines vertically and/or a specified number of columns horizontally in a text box. You can also scroll text programmatically, without any user interaction. This technique extends a text box's scrolling capabilities beyond those provided by its built-in properties and methods.
MORE INFORMATIONIn Visual Basic, you can scroll text in a text box vertically or horizontally by actively clicking the vertical or horizontal scroll bar respectively, at run time. However, the text always scrolls one line or one column per click of the scroll bar. Furthermore, there are no built-in properties or methods to scroll text without user interaction. To work around these limitations, you can call the Windows API SendMessage function using the EM_LINESCROLL message. SendMessage requires the following parameters:
SendMessage(hWnd, EM_LINESCROLL, wParam, lParam) where hWnd - is the hWnd of the text box. wParam - is used to specify the number of horizontal columns to scroll. A positive value causes text to scroll to the left. A negative value causes text to scroll to the right. lParam - is used to specify the number of vertical lines to scroll. A positive value causes text to scroll upward. A negative value causes text to scroll downward.SendMessage returns True if the text box is multiline and False if it is single-line. Note that calling SendMessage to scroll text vertically does not require a vertical scroll bar, but the length of text within the text box should exceed the text box height. To scroll text horizontally, a scroll bar is required.
Step-by-Step Example
Keywords : vb5all vb5howto VBKBCtrl VBKBInt VBKBStd VBKBTextBox VBKBWinAPI kbhowto Version : 5.0 Platform : WINDOWS Issue type : kbhowto |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |