Windows API Guide: CreateHatchBrush Function


Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Requires Windows CE 1.0 or later.

Description & Usage

Sending the EM_GETFIRSTVISIBLELINE message to a multi-line edit control finds out which line is the first line visible. This is the line that is currently displayed at the top of the control.

Return Value

If the edit control is multi-line, the message returns the zero-based index of the first visible line at the top of the control. If the edit control is single-line, the message returns the zero-based index of the first visible character.

Visual Basic-Specific Issues

None.

Parameters

wParam
Not used -- set to 0.
lParam
Not used -- set to 0.

Constant Definitions

Const EM_GETFIRSTVISIBLELINE = &HCE

Example

Read the first visible line at the top of edit control Text1. Display the text on that line in the Debug window. This requires sending a series of edit control messages, if we do this via the API. To use this example, place a text edit control named Text1 and a command button named Command1 on a form window. Make sure that the MultiLine property of Text1 is set to True before running the example. To get the first line of text, click button Command1.

' This code is licensed according to the terms and conditions listed here. ' Declarations and such needed for the example: ' (Copy them to the (declarations) section of a module.) Public Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source _ As Any, ByVal Length As Long) Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal _ Msg As Long, wParam As Any, lParam As Any) As Long Public Const EM_GETFIRSTVISIBLELINE = &HCE Public Const EM_GETLINE = &HC4 Public Const EM_LINEINDEX = &HBB Public Const EM_LINELENGTH = &HC1 ' *** Place the following code inside the form window. *** Private Sub Command1_Click() Dim lineindex As Long       ' index of the first visible line Dim charindex As Long       ' index of the first character on that line Dim linetextlen As Integer  ' length of that line (note the data type!) Dim linetext As String      ' receives the line's text Dim retval As Long          ' generic return value ' Get the zero-based index of Text1's first visible line. lineindex = SendMessage(Text1.hWnd, EM_GETFIRSTVISIBLELINE, ByVal CLng(0), ByVal CLng(0)) ' Get the zero-based index of the first character on that line.  This is ' need for the message we'll send next. charindex = SendMessage(Text1.hWnd, EM_LINEINDEX, ByVal lineindex, ByVal CLng(0)) ' Find out the number of characters on that line.  Note how ' we store this in a 16-bit value instead of the regular 32-bit Long. linetextlen = SendMessage(Text1.hWnd, EM_LINELENGTH, ByVal charindex, ByVal CLng(0)) ' Make enough room in the string to receive the text.  However, ' the string must be at least two bytes/characters long for what we'll do next. linetext = Space(IIf(linetextlen>= 2, linetextlen, 2)) ' EM_GETLINE wants the length of the string copied into the first ' two bytes of the string passed to it.  Unusual, but this is the simplest way around ' the two-message-parameter limit.  This is why linetextlen is only 16 bits long. CopyMemory ByVal linetext, linetextlen, Len(linetextlen) ' Finally, read the first line visible in Text1. retval = SendMessage(Text1.hWnd, EM_GETLINE, ByVal lineindex, ByVal linetext) ' In case we made the string too long (if the line was less than two ' characters long), shorten it back up. If linetextlen < 2 Then linetext = Left(linetext, linetextlen) ' Finally, display the text. Debug.Print "The first line visible in Text1 reads: "; linetext End Sub

Category

Edit Controls

Back to the Message list.
Back to the Reference section.


Last Modified: August 26, 2000
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/e/em_getfirstvisibleline.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net