Horizontal Scrollbar on TsChecklistbox

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #33332
    Sereby
    Participant

    Hoi,

    i have a function for TChecklistbox which adds a Horizontal Scrollbar to the CheckListBox.
    This one does work.. but when i try it for TsCheckListBox it is not working.

    any idea why?

    CODE
    procedure AddHScroll(DestListBox: TsCheckListBox);
    const LB_SETHORIZONTALEXTENT = $0194;
    var   I, intWidth, intMaxWidth: Integer;
    begin
      intMaxWidth := 0;
      for I := 0 to DestListBox.Items.Count – 1 do
      begin
        intWidth := DestListBox.Canvas.TextWidth(DestListBox.Items.Strings + 'X');
        if (intMaxWidth < intWidth) then
          intMaxWidth := intWidth;
      end;
      SendMessage(DestListBox.Handle, LB_SETHORIZONTALEXTENT, intMaxWidth + 20, 0);
    end;

    #40765
    Support
    Keymaster

    Hello

    Try to define a font of Canvas before calling TextWidth (I mean DestListBox.Canvas.Font.Assign(DestListBox.Font)).
    This horizontal scrollbar was tested already and was working well..

    #40773
    Sereby
    Participant

    hi,

    you are right.. in a fresh project it is working with this.. but in my big project it is not working.

    i was successful in creating a demo-app for you!

    Hope you can find the bug

    thanks

    #40775
    Support
    Keymaster

    Thank you for demo.
    This solution (LB_SETHORIZONTALEXTENT message) working if listbox is visible already seems.
    Try to call AddHScroll after UpdateFrame…

    #40776
    Sereby
    Participant

    thanks.

    but with the old TCheckListBox it is working without this!

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