View Issue Details

IDProjectCategoryView StatusLast Update
0034739LazarusLCLpublic2019-02-06 03:33
ReporterSerge AnvarovAssigned Towp 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWindowsOSWindowsOS VersionWindows 7
Product Version2.1 (SVN)Product Build 
Target Version2.0Fixed in Version 
Summary0034739: Windows. ListView with OwnerData ignore StateImages
DescriptionLCL does not process a request from the system to draw StateImages when OwnerData is true
Steps To ReproduceExample of project. Without the patch doesn't draw the check boxes.
After patch - do.
Additional InformationPatch included. Same on 2.0 RC2
TagsNo tags attached.
Fixed in Revision59881
LazTarget2.0
WidgetsetWin32/Win64
Attached Files
  • ListViewVirtualChecks.zip (2,275 bytes)
  • ListviewOwnerdataStateimages.diff (3,147 bytes)
    Index: lcl/interfaces/win32/win32wscustomlistview.inc
    ===================================================================
    --- lcl/interfaces/win32/win32wscustomlistview.inc	(revision 59875)
    +++ lcl/interfaces/win32/win32wscustomlistview.inc	(working copy)
    @@ -92,42 +92,51 @@
       begin
         LVInfo:= GetWin32WindowInfo(ALV.Handle);
         DataInfo := PNMLVOwnerData(NMHdr);
    -    if not Assigned(DataInfo) or (not ALV.OwnerData) then Exit;
    -
    +    if not Assigned(DataInfo) or (not ALV.OwnerData) then
    +      Exit;
         listitem := ALV.Items[DataInfo^.item.iItem];
    -    if not Assigned(listitem) then Exit;
    -
    -    if DataInfo^.item.iSubItem = 0 then
    +    if not Assigned(listitem) then
    +      Exit;
    +    if (DataInfo^.item.mask and LVIF_TEXT) <> 0 then
         begin
    -      txt := listitem.Caption;
    -      DataInfo^.item.mask := DataInfo^.item.mask or LVIF_IMAGE;
    -      DataInfo^.item.iImage := listitem.ImageIndex;
    -    end
    -    else
    -    begin
    -      idx := DataInfo^.item.iSubItem - 1;
    -      if idx < listitem.SubItems.Count then
    -        txt := listitem.SubItems[idx]
    +      if DataInfo^.item.iSubItem = 0 then
    +        txt := listitem.Caption
           else
    -        txt := '';
    -    end;
    -
    -    if txt <> '' then
    -    begin
    -      if DataInfo^.hdr.code = UInt(LVN_GETDISPINFOA) then
           begin
    -        LVInfo^.DispInfoTextA[LVInfo^.DispInfoIndex]:=Utf8ToAnsi(txt);
    -        DataInfo^.item.pszText := @(LVInfo^.DispInfoTextA[LVInfo^.DispInfoIndex][1]);
    +        idx := DataInfo^.item.iSubItem - 1;
    +        if idx < listitem.SubItems.Count then
    +          txt := listitem.SubItems[idx]
    +        else
    +          txt := '';
    +      end;
    +      if txt <> '' then
    +      begin
    +        if DataInfo^.hdr.code = UInt(LVN_GETDISPINFOA) then
    +        begin
    +          LVInfo^.DispInfoTextA[LVInfo^.DispInfoIndex]:=Utf8ToAnsi(txt);
    +          DataInfo^.item.pszText := @(LVInfo^.DispInfoTextA[LVInfo^.DispInfoIndex][1]);
    +        end
    +        else
    +        begin
    +          LVInfo^.DispInfoTextW[LVInfo^.DispInfoIndex]:=UTF8Decode(txt);
    +          DataInfo^.item.pszText := @(LVInfo^.DispInfoTextW[LVInfo^.DispInfoIndex][1]);
    +        end;
    +        inc(LVInfo^.DispInfoIndex);
    +        if LVInfo^.DispInfoIndex=LV_DISP_INFO_COUNT then LVInfo^.DispInfoIndex:=0;
           end
           else
    +        DataInfo^.item.pszText := nil;
    +    end;
    +    if (DataInfo^.item.mask and LVIF_IMAGE) <> 0 then
    +    begin
    +      DataInfo^.item.iImage := listitem.ImageIndex;
    +      if Assigned(ALV.StateImages) then
           begin
    -        LVInfo^.DispInfoTextW[LVInfo^.DispInfoIndex]:=UTF8Decode(txt);
    -        DataInfo^.item.pszText := @(LVInfo^.DispInfoTextW[LVInfo^.DispInfoIndex][1]);
    +        DataInfo^.item.state := IndexToStateImageMask(listitem.StateIndex + 1);
    +        DataInfo^.item.stateMask := $F000; // States start from 12 bit
    +        DataInfo^.item.mask := DataInfo^.item.mask or LVIF_STATE;
           end;
    -      inc(LVInfo^.DispInfoIndex);
    -      if LVInfo^.DispInfoIndex=LV_DISP_INFO_COUNT then LVInfo^.DispInfoIndex:=0;
    -    end else
    -      DataInfo^.item.pszText := nil;
    +    end;
       end;
     
       procedure HandleListViewCustomDraw(ALV: TCustomListViewAccess);
    

Relationships

related to 0034742 confirmedZeljan Rikalo Virtual ListView ignoring StateImages 

Activities

Serge Anvarov

2018-12-20 16:24

reporter  

ListViewVirtualChecks.zip (2,275 bytes)

Serge Anvarov

2018-12-20 16:24

reporter  

ListviewOwnerdataStateimages.diff (3,147 bytes)
Index: lcl/interfaces/win32/win32wscustomlistview.inc
===================================================================
--- lcl/interfaces/win32/win32wscustomlistview.inc	(revision 59875)
+++ lcl/interfaces/win32/win32wscustomlistview.inc	(working copy)
@@ -92,42 +92,51 @@
   begin
     LVInfo:= GetWin32WindowInfo(ALV.Handle);
     DataInfo := PNMLVOwnerData(NMHdr);
-    if not Assigned(DataInfo) or (not ALV.OwnerData) then Exit;
-
+    if not Assigned(DataInfo) or (not ALV.OwnerData) then
+      Exit;
     listitem := ALV.Items[DataInfo^.item.iItem];
-    if not Assigned(listitem) then Exit;
-
-    if DataInfo^.item.iSubItem = 0 then
+    if not Assigned(listitem) then
+      Exit;
+    if (DataInfo^.item.mask and LVIF_TEXT) <> 0 then
     begin
-      txt := listitem.Caption;
-      DataInfo^.item.mask := DataInfo^.item.mask or LVIF_IMAGE;
-      DataInfo^.item.iImage := listitem.ImageIndex;
-    end
-    else
-    begin
-      idx := DataInfo^.item.iSubItem - 1;
-      if idx < listitem.SubItems.Count then
-        txt := listitem.SubItems[idx]
+      if DataInfo^.item.iSubItem = 0 then
+        txt := listitem.Caption
       else
-        txt := '';
-    end;
-
-    if txt <> '' then
-    begin
-      if DataInfo^.hdr.code = UInt(LVN_GETDISPINFOA) then
       begin
-        LVInfo^.DispInfoTextA[LVInfo^.DispInfoIndex]:=Utf8ToAnsi(txt);
-        DataInfo^.item.pszText := @(LVInfo^.DispInfoTextA[LVInfo^.DispInfoIndex][1]);
+        idx := DataInfo^.item.iSubItem - 1;
+        if idx < listitem.SubItems.Count then
+          txt := listitem.SubItems[idx]
+        else
+          txt := '';
+      end;
+      if txt <> '' then
+      begin
+        if DataInfo^.hdr.code = UInt(LVN_GETDISPINFOA) then
+        begin
+          LVInfo^.DispInfoTextA[LVInfo^.DispInfoIndex]:=Utf8ToAnsi(txt);
+          DataInfo^.item.pszText := @(LVInfo^.DispInfoTextA[LVInfo^.DispInfoIndex][1]);
+        end
+        else
+        begin
+          LVInfo^.DispInfoTextW[LVInfo^.DispInfoIndex]:=UTF8Decode(txt);
+          DataInfo^.item.pszText := @(LVInfo^.DispInfoTextW[LVInfo^.DispInfoIndex][1]);
+        end;
+        inc(LVInfo^.DispInfoIndex);
+        if LVInfo^.DispInfoIndex=LV_DISP_INFO_COUNT then LVInfo^.DispInfoIndex:=0;
       end
       else
+        DataInfo^.item.pszText := nil;
+    end;
+    if (DataInfo^.item.mask and LVIF_IMAGE) <> 0 then
+    begin
+      DataInfo^.item.iImage := listitem.ImageIndex;
+      if Assigned(ALV.StateImages) then
       begin
-        LVInfo^.DispInfoTextW[LVInfo^.DispInfoIndex]:=UTF8Decode(txt);
-        DataInfo^.item.pszText := @(LVInfo^.DispInfoTextW[LVInfo^.DispInfoIndex][1]);
+        DataInfo^.item.state := IndexToStateImageMask(listitem.StateIndex + 1);
+        DataInfo^.item.stateMask := $F000; // States start from 12 bit
+        DataInfo^.item.mask := DataInfo^.item.mask or LVIF_STATE;
       end;
-      inc(LVInfo^.DispInfoIndex);
-      if LVInfo^.DispInfoIndex=LV_DISP_INFO_COUNT then LVInfo^.DispInfoIndex:=0;
-    end else
-      DataInfo^.item.pszText := nil;
+    end;
   end;
 
   procedure HandleListViewCustomDraw(ALV: TCustomListViewAccess);

Serge Anvarov

2018-12-20 16:27

reporter   ~0112757

https://forum.lazarus.freepascal.org/index.php/topic,43603.0.html

wp

2018-12-20 19:14

developer   ~0112761

Applied, thank you.

I am resolving since it solves the issue at least for Windows. On qt and gtk2 (I did not test others) it still persists.

Zeljan Rikalo

2018-12-20 19:29

developer   ~0112762

There's no issue about qt and gtk2 in this case, mean nobody opened it and attached example.

wp

2018-12-21 00:08

developer   ~0112770

Here it is if you need it: 0034742

Serge Anvarov

2019-02-06 03:33

reporter   ~0113884

In release

Issue History

Date Modified Username Field Change
2018-12-20 16:24 Serge Anvarov New Issue
2018-12-20 16:24 Serge Anvarov File Added: ListViewVirtualChecks.zip
2018-12-20 16:24 Serge Anvarov File Added: ListviewOwnerdataStateimages.diff
2018-12-20 16:27 Serge Anvarov Note Added: 0112757
2018-12-20 19:14 wp Fixed in Revision => 59881
2018-12-20 19:14 wp LazTarget => 2.0
2018-12-20 19:14 wp Note Added: 0112761
2018-12-20 19:14 wp Status new => resolved
2018-12-20 19:14 wp Resolution open => fixed
2018-12-20 19:14 wp Assigned To => wp
2018-12-20 19:14 wp Target Version => 2.0
2018-12-20 19:29 Zeljan Rikalo Note Added: 0112762
2018-12-21 00:06 wp Relationship added related to 0034742
2018-12-21 00:08 wp Note Added: 0112770
2019-02-06 03:33 Serge Anvarov Note Added: 0113884
2019-02-06 03:33 Serge Anvarov Status resolved => closed