VB3 Use Windows API Functions to Better Manipulate Text Boxes (76518)
The information in this article applies to:
- Microsoft Visual Basic Professional Edition for Windows 2.0
- Microsoft Visual Basic Professional Edition for Windows 3.0
This article was previously published under Q76518 SUMMARY
By calling Windows API functions from Microsoft Visual Basic for
Windows, you can retrieve text box (or edit control) information that
you cannot obtain using only Visual Basic for Windows' built-in features.
NOTE: In Visual Basic versions 2.0 and 3.0 for Windows, you can use the
new HWND property of a text box instead of calling the GetFocus() function.
This article supplies a sample program that performs the following
useful features (making use of the Windows message constants shown in
parentheses, obtained by calling Windows API routines):
- Copy a specific line of text from the text box (EM_GETLINE).
- Retrieve the number of lines within the text box (EM_GETLINECOUNT).
- Position the cursor at a specific character location (EM_GETSEL) in the
text box.
- Retrieve the line number of a specific character location in the text
box (EM_LINEFROMCHAR).
- Retrieve the amount of lines before a specified character position in
the text box (EM_LINEINDEX).
- Retrieve the amount of characters in a specified line in the text box
(EM_LINELENGTH).
- Replace specified text with another text string (EM_REPLACESEL).
For a separate article that explains how to specify the amount of text
allowable within a text control, query on the following word in the
Microsoft Knowledge Base:
REFERENCES
"Programming Windows: The Microsoft Guide to Writing Applications for
Windows 3," Charles Petzold, Microsoft Press, 1990
"Microsoft Windows Software Development Kit: Reference Volume 1,"
version 3.0
WINSDK.HLP file shipped with Microsoft Windows 3.0 Software Development Kit
Modification Type: | Major | Last Reviewed: | 10/30/2003 |
---|
Keywords: | kbcode KB76518 |
---|
|