SetWindowText Function

Declare Function SetWindowText Lib "user32.dll" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As Long

Platforms

Description & Usage

SetWindowText changes the text of a given window. Although this function can set the text of regular windows owned by other programs, it cannot change the text of a control owned by a different program. To set the text of those controls, use the WM_SETTEXT message instead.

Return Value

If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns a non-zero value.

Parameters

hWnd
A handle to the window to set the text of.
lpString
The string to set as the window's text.

Example

' This code is licensed according to the terms and conditions listed here.

' Set the title bar of window Form1 to "Generic Application 1.0".
Dim retval As Long  ' return value

retval = SetWindowText(Form1.hWnd, "Generic Application 1.0")

See Also

GetWindowText, WM_SETTEXT

Category

Windows

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: February 12, 2000.
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
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/s/setwindowtext.html