WM_SETTEXT Message

Platforms

Description & Usage

Sending the WM_SETTEXT message to a window sets that window's text. For ordinary windows, the text is the text that appears in the title bar. The message is handled by the target window's default window procedure.

Return Value

If the message returns 0, an error occured. If the message returns a non-zero value, the window text was successfully set.

Visual Basic-Specific Issues

When sending the WM_SETTEXT message, the expression ByVal CLng(0) must be used for the wParam parameter. Additionally, the ByVal keyword must also preceed the string passed as the lParam parameter.

Parameters

wParam
Not used -- set to 0.
lParam
The string to set as the window text.

Constant Definitions

Const WM_SETTEXT = &HC

Example

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

' Set the title bar text of window Form1 to "Caption Area".
' Do this by sending the proper message to a window.
Dim wintext As String  ' string to set as the window's text
Dim retval As Long  ' return value of message

' Store the desired text in a string.
wintext = "Caption Area"
' Send a message telling window Form1 to make that string its text.
retval = SendMessage(Form1.hWnd, WM_SETTEXT, ByVal CLng(0), ByVal wintext)

' Display the result of the message.
If retval = 0 Then
  Debug.Print "Unable to set the text of Form1."
Else
  Debug.Print "The text of Form1 was successfully set."
End If

See Also

SetWindowText, WM_GETTEXT

Category

Windows

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


Last Modified: January 25, 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/w/wm_settext.html