Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Controls
  New Posts New Posts RSS Feed - Codejock Listview Subitem Icons via SendMessage
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Codejock Listview Subitem Icons via SendMessage

 Post Reply Post Reply
Author
Message
Top3r View Drop Down
Newbie
Newbie


Joined: 28 March 2012
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Top3r Quote  Post ReplyReply Direct Link To This Post Topic: Codejock Listview Subitem Icons via SendMessage
    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


Back to Top
Top3r View Drop Down
Newbie
Newbie


Joined: 28 March 2012
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Top3r Quote  Post ReplyReply Direct Link To This Post Posted: 29 July 2013 at 5:23am
no one can help me?? I need this so much ^^
Back to Top
Willowmaster View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 July 2010
Location: Netherlands
Status: Offline
Points: 180
Post Options Post Options   Thanks (0) Thanks(0)   Quote Willowmaster Quote  Post ReplyReply Direct Link To This Post 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



Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.