Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

ListView Hack Question for Experts


  • Please log in to reply
5 replies to this topic
uselessdreamer
  • Members
  • 12 posts
  • Last active: Dec 18 2009 04:32 PM
  • Joined: 03 Nov 2008
I am experimenting with an undocumented hack I found wich allow state images in Listviews in columns other than first....

I want to avoid Ownerdraw to draw a strip of rating stars in column 3 and works, except for the fact the control makes space for the images in the first column, wheter or not I set them...

Posted Image

I am sure this is imposible, but maybe not... anyone knows any way of killing this empty space? I don't know if the space is made by the control or by the set image list function...

#Singleinstance, force 
Gui, Show, w500 h300, State Images Subcolumn Hack	
Gui, Add, ListView, x0 y0 w500 h300 -Checked LV -LV0x20 +LV0x00000002 HWNDhLV vLV, Filename|Type|Rating|Tags

IListStars := ImageList_Create(96, 16, 0x20, 48, 48) ;96x16 non standard imagelist
ImageListSmall := IL_Create(10) 
ImageListLarge := IL_Create(10,10,1) 

LV_SetImageList(ImageListLarge,0) 
LV_SetImageList(ImageListSmall,1) 
LV_SetImageList(IListStars,2) 

LV_ModifyCol(1,220) 
LV_ModifyCol(2,40) 
LV_ModifyCol(3,100) 

Loop 20  
{
    IL_Add(ImageListSmall, "shell32.dll", A_Index)  
    IL_Add(ImageListLarge, "shell32.dll", A_Index)  
}

IL_Add(IListStars, A_ScriptDir . "\star0.ico")    
IL_Add(IListStars, A_ScriptDir . "\star1.ico")     
IL_Add(IListStars, A_ScriptDir . "\star2.ico")     
IL_Add(IListStars, A_ScriptDir . "\star3.ico")     
IL_Add(IListStars, A_ScriptDir . "\star4.ico")     
IL_Add(IListStars, A_ScriptDir . "\star5.ico")     

Loop 10
    LV_Add("Icon" . A_Index, "This is item " . A_Index ,"JPG","","none")    
Loop 10
    LV_SetStateImage(hLV, A_Index, 3, A_Index)
 
LV_ModifyCol(4,"AutoHdr")  

WinSet, Redraw,, A

LV_SetStateImage(hList, iItem, iSubItem, iImage)
{ 
LVIS_STATEIMAGEMASK := 0xF000
LVIS_CUT := 0x0004
VarSetCapacity(LVITEM, 20, 0) 
LVM_SETITEM := 0x1006 
mask = 0x00000008   ; LVIF_STATE := 0x00000008 
iItem -- 
;iImage -- 
NumPut(mask, LVITEM, 0) 
NumPut(iItem, LVITEM, 4, "Int") 
NumPut(iSubItem, LVITEM, 8, "Int") 
NumPut(iImage<<12, LVITEM, 12, "UInt") 
NumPut(LVIS_STATEIMAGEMASK, LVITEM, 16, "UInt") 

result := DllCall("SendMessageA", UInt, hList, UInt, LVM_SETITEM, UInt, 0, UInt, &LVITEM) 
return, result 
}

ImageList_Create(cx,cy,flags,cInitial,cGrow){ 
   return DllCall("comctl32.dll\ImageList_Create", "int", cx, "int", cy, "uint", flags, "int", cInitial, "int", cGrow) 
} 

ImageList_Add(hIml, hbmImage, hbmMask=""){ 
   return DllCall("comctl32.dll\ImageList_Add", "uint", hIml, "uint",hbmImage, "uint", hbmMask) 
}

You will need the 96x16 Star icons
<!-- m -->http://www.autohotke... ... s96x16.zip<!-- m -->
Thanks in advance...

Leef_me
  • Moderators
  • 8510 posts
  • Last active: Sep 10 2015 05:50 AM
  • Joined: 08 Apr 2009
I expect the culpret would be
LV_ModifyCol(1,220)
but I get no stars :sad: My script and star icons are in the same directory

---------------------------
ahk_version.ahk
---------------------------
A_AhkVersion = 1.0.48.00
A_OSVersion = WIN_VISTA
A_OSType = WIN32_NT
A_IsAdmin = 1
---------------------------
OK
---------------------------

uselessdreamer
  • Members
  • 12 posts
  • Last active: Dec 18 2009 04:32 PM
  • Joined: 03 Nov 2008

but I get no stars My script and star icons are in the same directory


Haven't tested on Vista.. maybe the hack works only on XP :(

NumPut(mask, LVITEM, 0) 
NumPut(iItem, LVITEM, 4, "Int") 
;NumPut(iSubItem, LVITEM, 8, "Int") <-- COMMENT THIS LINE
NumPut(iImage<<12, LVITEM, 12, "UInt") 
NumPut(LVIS_STATEIMAGEMASK, LVITEM, 16, "UInt")

Try to comment that line in the function, it will set the stars in the first column... and see if it works now...

[ADDED]
If it works try also to change -CHECKED to +CHECKED in Listview options... and click on the stars... kind of cool for a simple rating solution, if you can live with the fact the stars are on the left...