lbOwnerDrawFixed listbox problem

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #38127
    JM-DG
    Participant

    Hi!

    I use alpha controls in a Delphi 7 project & I have a custom painted listbox.

    I use the lbOwnerDrawFixed style in order to display custom texts, have custom disposition, custom selection color & current item doubleclicked styled. I use the onDrawItem event.

    It seems that whenever I modify the default canvas font, brush color, font color, this problem occurs: The items post-selection turn black.

    When elements with changed default color (double clicked or selected) get out of the list view items are painted back to their regular/normal color.

    See gif for problem in action.

    c3ce08d33ca46d4876dc3050cae0acea.gif

    I've also attached a simplified demo of the problem.

    Thank you for your time! 🙂

    #58958
    Support
    Keymaster

    Thank you for the demo.

    This issue will be solved in the nearest release, I think.

    #58971
    JM-DG
    Participant
    'Support' wrote:

    Thank you for the demo.

    This issue will be solved in the nearest release, I think.

    sListBox.pas line +/-512 in procedure TsCustomListBox.WMPaint(var Message: TWMPaint)

    After a quick investigation, I think the problem is that a font always gets assigned to the canvas even when there is already one assigned.

    It seems like simply adding this condition does the trick.

    Code:
    if (assigned(Canvas.Font) = false) then
    Canvas.Font.Assign(Font);
    #58984
    JM-DG
    Participant

    o/

    There seems to still have an issue with the listbox on the latest version: 14.14.

    Code:
    Canvas.Font.OnChange := nil;

    doesn't seem to do the trick 100%.

    In the demo I provided, I believe the selected item is supposed to have a black font color (with the graphite skin, at least). See demo in first post.

    The selected item seems to lose its color on repaint.

    See gif.

    3c30e2c18bce3879e622254631325ad6.gif

    However,

    Code:
    if(Assigned(Canvas.Font) = false) then
    Canvas.Font.Assign(Font);

    seems to behave correctly.

    Also, while doing some other tests, I realised that I was losing my selection color (multiselect) when scrolling down to select more items & a repaint seem to paint back the background.

    See gif.

    ddd166c3228f22f383fb6cf7d63fe03d.gif

    Thank you for your time. 🙂

    #58990
    Support
    Keymaster

    I will check it soon.

    #59007
    Support
    Keymaster

    I have added your checking there, but it doesn't work.

    It's strange that this code did a trick on your side.

    “Assign(Font)” doesn't create a new TFont, this method just assigns font properties like Size, Color, etc..

    I will research more your demo.

    #59008
    JM-DG
    Participant
    'Support' wrote:

    I have added your checking there, but it doesn't work.

    It's strange that this code did a trick on your side.

    “Assign(Font)” doesn't create a new TFont, this method just assigns font properties like Size, Color, etc..

    I will research more your demo.

    Huh. Odd. Maybe my “fix” is more a hack which only works in Delphi 7? That's what I'm using.

    #59014
    Support
    Keymaster

    Look the PM, I have sent you the patched file.

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