On Thu, Jun 03, 2004 at 02:12:49PM -0700, Krishna Murthy wrote:
While inserting the item in ListView control in wine( in function ISTVIEW_InsertItemT() ), the state image index is overwritten with zeros. After copying the LVITEM structure to newly created item in LISTVIEW_InsertItemT(), a statement is unnecessarily masking the state with LVIS_STATEIMAGEMASK by using ~ operator (item.state &= ~LVIS_STATEIMAGEMASK; ). This statement is making the bits 12 through 15 overwrite with 0's by replacing original state image index.
Odd, I've added that, but I can not understand why. If anything, it might be a typo, as I can't see why I would want to nuke the state image, but I also can not remember what I wanted to remove. So the patch is OK, I'll think some more tonight what, if anything, I wanted to remove from the state.
Odd, I've added that, but I can not understand why. If anything, it might be a typo, as I can't see why I would want to nuke the state image, but I also can not remember what I wanted to remove. So the patch is OK, I'll think some more tonight what, if anything, I wanted to remove from the state.
Now I know why I did that. Documentation from LVM_INSERTITEM says: (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla...) ... If a list-view control has the LVS_EX_CHECKBOXES style set, any value placed in bits 12 through 15 of the state member of the LVITEM structure will be ignored. When an item is added with this style set, it will always be set to the unchecked state. ...
Documentation for LVITEM.state, says: (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla...) ... Bits 12 through 15 of this member specify the state image index. The state image is displayed next to an item's icon to indicate an application-defined state. If these bits are zero, the item has no state image. To isolate these bits, use the LVIS_STATEIMAGEMASK mask. To set the state image index, use the INDEXTOSTATEIMAGEMASK macro. The state image index specifies the index of the image in the state image list that should be drawn. The state image list is specified with the LVM_SETIMAGELIST message. ...
So I guess we need to clear the bits only if LVS_EX_CHECKBOXES is set.
ChangeLog Clear the state image bits only if LVS_EX_CHECKBOXES is set. Fix obvious logical error in focus handling. Indentation and formatting fixes. (based on a patch by Krishna Murthy).
Index: dlls/comctl32/listview.c =================================================================== RCS file: /var/cvs/wine/dlls/comctl32/listview.c,v retrieving revision 1.388 diff -u -r1.388 listview.c --- dlls/comctl32/listview.c 11 May 2004 22:16:54 -0000 1.388 +++ dlls/comctl32/listview.c 4 Jun 2004 04:41:46 -0000 @@ -3317,7 +3317,7 @@ ranges_delitem(infoPtr->selectionRanges, lpLVItem->iItem); /* if we are asked to change focus, and we manage it, do it */ - if (lpLVItem->state & lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED) + if (lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED) { if (lpLVItem->state & LVIS_FOCUSED) { @@ -6041,7 +6041,7 @@ }
/*** - * nESCRIPTION: + * DESCRIPTION: * Inserts a new item in the listview control. * * PARAMETER(S): @@ -6072,8 +6072,7 @@
if (!is_assignable_item(lpLVItem, infoPtr->dwStyle)) return -1;
- if ( !(lpItem = (ITEM_INFO *)Alloc(sizeof(ITEM_INFO))) ) - return -1; + if (!(lpItem = (ITEM_INFO *)Alloc(sizeof(ITEM_INFO)))) return -1;
/* insert item in listview control data structure */ if ( !(hdpaSubItems = DPA_Create(8)) ) goto fail; @@ -6094,21 +6093,21 @@ /* set the item attributes */ if (lpLVItem->mask & (LVIF_GROUPID|LVIF_COLUMNS)) { - /* full size structure expected - _WIN32IE >= 0x560 */ - item = *lpLVItem; + /* full size structure expected - _WIN32IE >= 0x560 */ + item = *lpLVItem; } else if (lpLVItem->mask & LVIF_INDENT) { - /* indent member expected - _WIN32IE >= 0x300 */ - memcpy(&item, lpLVItem, offsetof( LVITEMW, iGroupId )); + /* indent member expected - _WIN32IE >= 0x300 */ + memcpy(&item, lpLVItem, offsetof( LVITEMW, iGroupId )); } else { - /* minimal structure expected */ - memcpy(&item, lpLVItem, offsetof( LVITEMW, iIndent )); + /* minimal structure expected */ + memcpy(&item, lpLVItem, offsetof( LVITEMW, iIndent )); } item.iItem = nItem; - item.state &= ~LVIS_STATEIMAGEMASK; + if (infoPtr->dwLvExStyle & LVS_EX_CHECKBOXES) item.state &= ~LVIS_STATEIMAGEMASK; if (!set_main_item(infoPtr, &item, TRUE, isW, &has_changed)) goto undo;
/* if we're sorted, sort the list, and update the index */