Print Page | Close Window

Codejock Listview Subitem Icons via SendMessage

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=21816
Printed Date: 26 April 2024 at 4:59am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Codejock Listview Subitem Icons via SendMessage
Posted By: Top3r
Subject: Codejock Listview Subitem Icons via SendMessage
Date Posted: 25 July 2013 at 5:20am
Hi,
im getting crazy..


Im trying to add Icons to Subitems with a Codejock Listview (using vb6)


I found a Code for the Standard Listview from MS, there the Code works fine.

The Problem is that in the Codejock Listview i get no error and the "Icon Space" is there, but the Icon gets not drawed..



Here my Code..

The Result with MS Listview:





The Result with Codejock Listview:





Option Explicit

Private Declare Function SendMessageLong Lib "user32" Alias _
        "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
        ByVal wParam As Long, ByVal lParam As Long) As Long
       
Private Declare Function SendMessage Lib "user32" Alias _
        "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
        ByVal wParam As Long, lParam As Any) As Long

Private Type LVITEM
    mask As Long
    iItem As Long
    iSubItem As Long
    state As Long
    stateMask As Long
    pszText As String
    cchTextMax As Long
    iImage As Long
    lParam As Long
    iIndent As Long
End Type

Private Const LVM_FIRST As Long = &H1000&
Private Const LVM_GETEXTENDEDLISTVIEWSTYLE As Long = (LVM_FIRST + 55)
Private Const LVM_SETEXTENDEDLISTVIEWSTYLE As Long = (LVM_FIRST + 54)
Private Const LVS_EX_SUBITEMIMAGES As Long = &H2&
Private Const LVIF_IMAGE As Long = &H2&
Private Const LVM_SETITEM As Long = (LVM_FIRST + 6)


Private Sub Form_Load()
Dim i As Integer

For i = 1 To 3
    lv.ColumnHeaders.Add , , i, lv.Width / 4 - 100
Next

lv.Icons = img.Icons
lv.IconSize = 16

    With lv
        .ListItems.Add 1, , "Eintrag 1", 1
        .ListItems.Add 2, , "Eintrag 2", 4
        .ListItems.Add 3, , "Eintrag 3", 5
       
        .ListItems.Item(1).SubItems(1) = "Eintrag 1B"
        .ListItems.Item(1).SubItems(2) = "Eintrag 1C"
       
        .ListItems.Item(2).SubItems(1) = "Eintrag 2B"
        .ListItems.Item(2).SubItems(2) = "Eintrag 2C"
       
        .ListItems.Item(3).SubItems(1) = "Eintrag 3B"
        .ListItems.Item(3).SubItems(2) = "Eintrag 3C"
    End With
   

End Sub

Private Sub Command1_Click()
    Call SetLVSubImages(lv, 1, 1, 1, True)
    Call SetLVSubImages(lv, 1, 2, 2, True)
   
    Call SetLVSubImages(lv, 2, 1, 3, True)
    Call SetLVSubImages(lv, 2, 2, 4, True)
   
    Call SetLVSubImages(lv, 3, 1, 5, True)
    Call SetLVSubImages(lv, 3, 2, 6, True)
End Sub

Private Sub SetLVSubImages(lv As ListView, ByVal Index, ByVal Column As Long, _
    ByVal Image As Long, ByVal SubImagesOn As Boolean)
   

   
    Dim lvStyle As Long, LV_Item As LVITEM
   
    lvStyle = SendMessageLong(lv.hwnd, _
              LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
   
    If SubImagesOn Then
        lvStyle = lvStyle Or LVS_EX_SUBITEMIMAGES
    Else
        lvStyle = lvStyle And Not LVS_EX_SUBITEMIMAGES
    End If
   
    Call SendMessageLong(lv.hwnd, _
         LVM_SETEXTENDEDLISTVIEWSTYLE, 0, lvStyle)
   
    If SubImagesOn Then
        With LV_Item
            .mask = LVIF_IMAGE
            .iSubItem = Column
            .iItem = Index - 1
            .iImage = Image
        End With
       
       
       
       
        Call SendMessage(lv.hwnd, LVM_SETITEM, Index - 1, LV_Item)
    End If
   
End Sub




The only difference in the Code from the MS Listview is that on the end they are Refreshing the Listview with lv.REFRESH

But the Codejock Listview does not has this .Refresh Sub..
And the codejock Listview hasn't the ListSubitems(x).ReportIcon :(



Can anybody help me??


I uploaded the Sourcecode too if someone wants to test it..
uploads/7412/Listview_Problem.zip" rel="nofollow - uploads/7412/Listview_Problem.zip





Replies:
Posted By: Top3r
Date Posted: 29 July 2013 at 5:23am
no one can help me?? I need this so much ^^


Posted By: Willowmaster
Date Posted: 16 October 2013 at 6:41am
I tried to set the first column the same way you set the subitems. That doesn't work. Second I tried to get the Icon handle by calling img.Icons.GetImage(1, 16).Handle and pass I to the SetLVSubImages function, but that doesn't work either. I don't think it's possible. Why don't you try the ReportControl? It does support this function and much more.

-------------
Product: Xtreme SuitePro (ActiveX) version 15.3.1

Platform: Windows XP (32bit) - SP 3 (on VMWare)

Language: Visual Basic 6.0






Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net