TsListView CustomDrawItem issue

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #35317
    Hamilton
    Participant

    Hi,

    I noticed a glitch with TsListView today where if the CustomDrawItem method is used then the cell lines are drawn the wrong color. Easier to explain with pictures:

    * DrawSubItem shows the list view when the sub items are colored. No problems there.

    * DrawItem shows the list view when the items are colored. Notice the recurring color bands on the cell borders.

    If I do the same thing with TListView components instead of TsListView components then the problem does not occur.

    My demo program is using a number of 3rd party components so I cannot provide that easily. To repro the problem:

    * Put a TsListView on the form.

    * Add several columns.

    * Add values for the columns at runtime using code similar to that below:

    ListItem := lvContacts.Items.Add;

    ListItem.Caption := 'Whatever';

    ListItem.SubItems.Add('Test1');

    ListItem.SubItems.Add('aaaaaa');

    * Add an OnCustomDrawItem event that does:

    if SameText(Item.SubItems[0], 'Test1') then

    begin

    Sender.Canvas.Font.Color := clSilver;

    Sender.Canvas.Brush.Color := clGreen;

    end

    else

    begin

    Sender.Canvas.Font.Color := clBlack;

    Sender.Canvas.Brush.Color := clWhite;

    end;

    * Add an OnCustomDrawSubItem event that does:

    if (SubItem in [1,2]) and SameText(Item.SubItems[0], 'Test1') then

    begin

    Sender.Canvas.Font.Color := clSilver;

    Sender.Canvas.Brush.Color := clGreen;

    end

    else

    begin

    Sender.Canvas.Font.Color := clBlack;

    Sender.Canvas.Brush.Color := clWhite;

    end;

    If it takes too long to repro then drop me a line and I'll put together a demo. Not a terribly high priority for me on this one, it looks a bit silly but it isn't a functional problem and only affects 1 screen in one app so I can be patient for a fix 🙂

    Regards,

    Hamilton

    #48813
    Hamilton
    Participant

    Just to add to the bug report: the issue occurs regardless of whether the checkboxes are shown (the screen grab shows checkboxes).

    I don't know if this is the right path or not but IIRC the list view draws the first column border and then copies that to the other columns; it may just be that the cell color for the first column is being drawn one or so pixels too far to the left and entering the region that is copied?

    Regards,

    Hamilton

    #48864
    Support
    Keymaster

    Hi!

    I'll try to fix it in the nearest release.

    #48938
    Hamilton
    Participant

    Fixed in 7.69. However, I noticed you have made font for the selected row bold for all columns except the first one – I suspect this may be an oversight not to include the first column?

    Regards,

    Hamilton

    #48967
    Support
    Keymaster
    'Hamilton' wrote:
    I noticed you have made font for the selected row bold for all columns except the first one – I suspect this may be an oversight not to include the first column?

    Please show what you mean.

    #48976
    Hamilton
    Participant

    Hi Serge,

    Please refer to the attached demo program. The demo shows two list views – the top one is TsListView with the Golden skin, the lower one is an unskinned TListView. Some issues you might notice:

    1. Select the first row in the top grid. Then click in the edit to give it focus. Mouseover the top grid and notice the second row goes bold in all columns except the first one. The first row doesn't go bold. The TListView is there as a control – it shows that the VCL control doesn't make the selected row bold in any circumstance.

    2. In the code, remove the code from the CustomDrawItem and CustomDrawSubItem procedures, save to remove the declaration and recompile. You'll now notice that the TsListView makes the selected row bold in all columns except the first one.

    I was consistently getting a combination of issues #1 and #2 above right up until the point where I attached the code – then I went to check something to write this thread and it didn't happen any more. I have no idea why and no time to work it out right now, but basically I was getting the bold row at the same time as having the colored rows.

    Another thing I noticed intermittently was that fast mouse-over movements when the grid had focus sometimes caused the row to be bold (as opposed to issue #1 above where it happens consistently when the edit control has focus).

    HTH

    Regards,

    Hamilton

    #48979
    Support
    Keymaster

    Thank you, I see now and I'll fix it very soon.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.