K
klaus via .NET 247
what is wrong?
Public Declare Auto Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As LVITEM) As Long
Public Structure LVITEM
Dim mask As Long
Dim iItem As Long
Dim iSubItem As Long
Dim State As Long
Dim stateMask As Long
Dim pszText As String
Dim cchTextMax As Long
Dim iImage As Long
Dim lParam As Long
Dim iIndent As Long
Dim iGroupId As Long
Dim cColumns As Long
Dim puColumns As Long
End Structure
Public Const LVIF_TEXT = &H1
Public Const LVIF_IMAGE = &H2
Public Const LVIF_PARAM = &H4
Public Const LVIF_STATE = &H8
Public Const LVIF_INDENT = &H10
Public Const LVIF_GROUPID = &H100
Public Const LVIF_COLUMNS = &H200
Public Const LVM_FIRST = &H1000&
Public Const LVM_INSERTITEMA = (LVM_FIRST + 7)
Public Const LVM_INSERTITEM = LVM_INSERTITEMA
Public Const LVM_GETITEMCOUNT = (LVM_FIRST + 4)
Private Sub fAddItem(ByVal sText As String, Optional ByVal lIndex As Long = 1, Optional ByVal iIcon As Long = -1, Optional ByVal iIndent As Long = 0, Optional ByVal lItemData As Long = 0)
Dim tLV As LVITEM
Dim lR As Long
tLV.pszText = sText & vbNullChar
tLV.cchTextMax = Len(sText) + 1
tLV.iImage = iIcon
tLV.iIndent = iIndent
tLV.lParam = lItemData
tLV.iItem = lIndex - 1
tLV.mask = LVIF_TEXT Or LVIF_IMAGE Or LVIF_PARAM Or LVIF_INDENT
lR = SendMessage(Me.ListView1.Handle, LVM_INSERTITEM, 0&, tLV)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call fAddItem("test")
End Sub
Public Declare Auto Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As LVITEM) As Long
Public Structure LVITEM
Dim mask As Long
Dim iItem As Long
Dim iSubItem As Long
Dim State As Long
Dim stateMask As Long
Dim pszText As String
Dim cchTextMax As Long
Dim iImage As Long
Dim lParam As Long
Dim iIndent As Long
Dim iGroupId As Long
Dim cColumns As Long
Dim puColumns As Long
End Structure
Public Const LVIF_TEXT = &H1
Public Const LVIF_IMAGE = &H2
Public Const LVIF_PARAM = &H4
Public Const LVIF_STATE = &H8
Public Const LVIF_INDENT = &H10
Public Const LVIF_GROUPID = &H100
Public Const LVIF_COLUMNS = &H200
Public Const LVM_FIRST = &H1000&
Public Const LVM_INSERTITEMA = (LVM_FIRST + 7)
Public Const LVM_INSERTITEM = LVM_INSERTITEMA
Public Const LVM_GETITEMCOUNT = (LVM_FIRST + 4)
Private Sub fAddItem(ByVal sText As String, Optional ByVal lIndex As Long = 1, Optional ByVal iIcon As Long = -1, Optional ByVal iIndent As Long = 0, Optional ByVal lItemData As Long = 0)
Dim tLV As LVITEM
Dim lR As Long
tLV.pszText = sText & vbNullChar
tLV.cchTextMax = Len(sText) + 1
tLV.iImage = iIcon
tLV.iIndent = iIndent
tLV.lParam = lItemData
tLV.iItem = lIndex - 1
tLV.mask = LVIF_TEXT Or LVIF_IMAGE Or LVIF_PARAM Or LVIF_INDENT
lR = SendMessage(Me.ListView1.Handle, LVM_INSERTITEM, 0&, tLV)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call fAddItem("test")
End Sub