I can't remember who, but at some point somebody was asking questions about getting and setting the state of the checkboxes that can be enabled in the ListView control...was this ever resolved?
I imagine I can turn them off and just use the selected items, but what is the point of the checkboxes if there is no way of determining their state???
Hmm, I found ListView_GetCheckState and ListView_SetCheckState...online and not in the documentation. Looks like it still works with the main OS versions though.
Looks like there isn't much for ListViews like ListBoxes where I can get the items easier without having to scan every item.
Well, I decided to go with selections and turned off my checkboxes. Here is some code to put in the custom message of your listview controls if you want some functionality like Explorer has, the LVN_KEYDOWN looked a little too complicated just for what I needed, so I put them here:
If wMsg= %WM_KEYDOWN Then
Select Case wParam
Case %VK_F5
RefreshFileList
Function = %TRUE
Case %VK_A
If (GetKeyState(%VK_CONTROL) And &H8000)= &H8000 Then
'Select All Files
For itemCount= 0 To SendMessage(HWND_HTML_FILELIST,%LVM_GETITEMCOUNT,0,0) - 1
ListView_SetItemState(HWND_HTML_FILELIST,itemCount,%LVIS_SELECTED,%LVIS_SELECTED)
Next itemCount
Function = %TRUE
End If
End Select
End If
Paul,
GetKeyState might also improve your FF_GetKeyState and eliminate the array for GetKeyboardState. For the toggle state you'd have to And with 1 I believe for CAPS/NUM/SCROLL, etc. Might even be able to do away with it all together and use the return value to set the text for the statusbar right in the KEYBOARD_HTML_STATUSBAR code. Something like an IIF$ line.
I wanted checkboxes in listboxes or treeviews a few weeks back. Nothing came of it and in the end I dealt with it via owner-drawn listboxes.
It's a pity that Microsoft made the checkbox listbox so damned complex to use. In VB it's a piece of cake, but in other development languages you have to jump thru hoops.
Andrew
Yeah, I didn't even understand the whole LVIS_STATEIMAGEMASK and INDEXTOSTATEIMAGEMASK stuff, or why PB uses 1 - (ISTRUE fCheck) in the function call??? None of it looked right. Maybe someone else here has worked with it and can explain it. I was sitting here forever just trying to figure out how to use it and thinking I needed to do that just to set the selection state too, then I just looked at the state bits and they all had their own spot, so I did it the way I made the function above. The docs don't mention much, they just show it needing a mask and mask bits...then when you go in to look at what states it has it goes off talking about INDEXTOSTATEIMAGEMASK and they only really have macros for the check state like we are supposed to figure out the rest going off of what they say for it.
INDEXTOSTATEIMAGEMASK does talk about TreeViews as well, so you should be able to use them just like the Listviews, Paul has the checkbox style in the Window styles of the TreeView though instead of out in the properties like the ListView has it.