- This topic has 5 replies, 3 voices, and was last updated 7 years, 2 months ago by HeDiBo.
-
AuthorPosts
-
September 6, 2017 at 2:01 pm #37587HeDiBoParticipant
A TsListView with auto width column shows a horizontal scrollbar but it should not (column width is automatic):
[attachment=8441:ListViewBug.jpg]
September 8, 2017 at 12:13 pm #57026HeDiBoParticipant'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
September 9, 2017 at 4:35 am #57033SupportKeymasterHello!
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
September 10, 2017 at 3:42 pm #57043HeDiBoParticipant'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 accessibleTsListview = 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.
September 11, 2017 at 3:19 am #57044molParticipantTry this one, Dick:
September 11, 2017 at 9:58 am #57045HeDiBoParticipant'mol' wrote:Try this one, Dick:
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
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
-
AuthorPosts
- You must be logged in to reply to this topic.