TsListView in vsReport mode shows improper horizontal scrollbar

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #37587
    HeDiBo
    Participant

    A TsListView with auto width column shows a horizontal scrollbar but it should not (column width is automatic):

    [attachment=8441:ListViewBug.jpg]

    #57026
    HeDiBo
    Participant
    'HeDiBo' wrote:

    A TsListView with auto width column shows a horizontal scrollbar but it should not (column width is automatic):

    [attachment=8441:ListViewBug.jpg]

    Contrary to the release notes, this problem is not solved in AC 12.16

    This problem only occurs if the Columns[n].AutoSize is True

    #57033
    Support
    Keymaster

    Hello!

    It was another problem.

    Your problem is inherited from standard TListView component and I will try to solve it soon.

    PS. Look, maybe it helps: https://stackoverflow.com/questions/4345407/autosize-columns-for-tlistview

    #57043
    HeDiBo
    Participant
    'Support' wrote:

    Hello!

    It was another problem.

    Your problem is inherited from standard TListView component and I will try to solve it soon.

    You're in for a real treat.

    I searched for two days now for a solution to hide the horizontal scrollbar in a standard TListView: it simply is not possible (none of the suggested solutions worked), since it is a very old flaw in the Windows implementation.

    The closest I got was this:

    Code:
    // Make WMPaint accessible

    TsListview = Class( sListView.TsListview )
    protected
    procedure WMPaint( var msg: TMessage); message WM_PAINT;
    end{class override};
    .
    .
    .
    // Every time hide the scrollbar, but disable it too, because now and then it still appears during manual scroll.
    procedure TsListview.WMPaint(var msg: TMessage);
    begin
    EnableScrollBar( Self.Handle, SB_HORZ, ESB_DISABLE_BOTH );
    ShowScrollBar(Self.Handle, SB_HORZ, FALSE);
    inherited;
    .
    .
    .
    // During Form/Frame initialization:
    .
    .
    ShowScrollBar(sListView1.Handle, SB_HORZ, FALSE);
    .
    .

    It's not pretty at all

    In AC there may be an extra possibility. Since AC has to draw the scrollbars itself, it may prevent drawing scrollbars using the information of an extra property (SB stands for Scrollbar, LV stands for ListView):

    SBVisibility: TLVSBVisibility

    Where TLVSBVisibility is: (LVSBStandard, LVSBBoth, LVSBHorz, LVSBVert, LVSBNone}

    in which LVSBStandard would be default and mean: don't change the scrollbar behavior.

    I look forward to such a solution.

    #57044
    mol
    Participant
    #57045
    HeDiBo
    Participant
    'mol' wrote:

    Thanks, I already found that one. It sets the bar for every message that reaches the listview. A total overkill and it has the danger of getting in a loop, because it assumes that setting the bar will not result in any message to the ListBox.

    In the mean time, Serge has come up with a different approach: although the column is set to AutoSize, the listview still needs this set all the time:

    Code:
    ListView_SetColumnWidth(Handle, , LVSCW_AUTOSIZE_USEHEADER);

    which appears to do the same a1.gif

    However, doing it this way my problem is solved:

    Code:
    TsListview = Class( sListView.TsListview )
    protected
    procedure WMPaint( var msg: TMessage); message WM_PAINT;
    end{class override};
    .
    .
    uses Winapi.CommCtrl;
    .
    .
    {$J+}
    procedure TsListview.WMPaint(var msg: TMessage);
    const
    inpaint: Boolean = False;
    var
    i: Integer;
    begin
    if not inpaint then begin
    for i := 0 to Columns.Count – 1 do begin
    if Columns.AutoSize then begin
    inpaint := True;
    ListView_SetColumnWidth(Handle, i, LVSCW_AUTOSIZE_USEHEADER);
    inpaint := False
    end{if};
    end{for};
    end{if};
    inherited;
    end;
    {$J-}

    It's very weird, but it works.

    Thank you, Serge, for finding this a7.gif

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