LB_RESETCONTENT Message

Platforms

Description & Usage

Sending the LB_RESETCONTENT message to a list box removes all items from it.

Return Value

This message always returns zero.

Visual Basic-Specific Issues

None.

Parameters

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

Constant Definitions

Const LB_RESETCONTENT = &H184

Example

When the user clicks button Command1, empty the list box List1, and then add three strings to it. The order in which the strings appear will depend on whether the list box is sorted or not.

To use this example, place a list box named List1 and a command button named Command1 on a form window. To verify that the list box's list is being emptied, you may wish to add some items to it before running the example.

' 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 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 LB_ADDSTRING = &H180
Public Const LB_RESETCONTENT = &H184

' *** Place the following code inside a form window. ***

Private Sub Command1_Click()
	Dim retval As Long  ' return value
	
	' Empty the list box List1.
	retval = SendMessage(List1.hWnd, LB_RESETCONTENT, ByVal CLng(0), ByVal CLng(0))
	
	' Now add three strings to List.  Their exact placement will
	' depend on whether List1 is sorted or not.
	retval = SendMessage(List1.hWnd, LB_ADDSTRING, ByVal CLng(0), ByVal "First Item Added")
	retval = SendMessage(List1.hWnd, LB_ADDSTRING, ByVal CLng(0), ByVal "Second Item Added")
	retval = SendMessage(List1.hWnd, LB_ADDSTRING, ByVal CLng(0), ByVal "Last Item Added")
End Sub

See Also

LB_ADDSTRING, LB_DELETESTRING, LB_INSERTSTRING

Category

List Boxes

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


Last Modified: December 17, 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/l/lb_resetcontent.html