Steve
May 19, 2020, 7:42am
1
Control.columns.AutoSize() seems to resize the columns to the width of the widest item for that column in the listview control. If that’s narrower than the column title the title is truncated rather than the column width resizing to suit the title.
Is this by design or a buglette?
Leo
May 19, 2020, 11:06am
2
Are you only seeing this with the last column, when the listview isn't wide enough to fit it in without scrolling? Or with all columns?
Steve
May 19, 2020, 11:21am
3
It seems to happen with the second or third column in a listview containing four or more cols. Not at pc atm to check and test.
Happens with a listview that has no need to horizontal scroll.
Leo
May 19, 2020, 11:32am
4
Seems OK here:
function OnClick(clickData) {
var Dlg = DOpus.Dlg;
Dlg.window = clickData.func.sourcetab;
Dlg.template = "dialog1";
Dlg.detach = true;
Dlg.Show();
var listview = Dlg.Control("listview1");
listview.AddItem("Test 1");
listview.GetItemByName("Test 1").subitems(0) = "Test Sub 1.1";
listview.GetItemByName("Test 1").subitems(1) = "Test Sub 1.2";
listview.AddItem("Test 2");
listview.GetItemByName("Test 2").subitems(0) = "Test Sub 2.1";
listview.GetItemByName("Test 2").subitems(1) = "Test Sub 2.2";
while (true) {
var Msg = Dlg.GetMsg();
if (!Msg.result) break;
DOpus.Output("Msg Event = " + Msg.event);
if (Msg.event == "click" && Msg.control == "Autosize") {
listview.columns.AutoSize();
}
}
DOpus.Output("Return code = " + Dlg.result);
}
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
<label>New Button</label>
<icon1>#newcommand</icon1>
<function type="script">
<instruction>@script JScript</instruction>
<instruction>function OnClick(clickData) {</instruction>
<instruction> var Dlg = DOpus.Dlg;</instruction>
<instruction> Dlg.window = clickData.func.sourcetab;</instruction>
<instruction> Dlg.template = "dialog1";</instruction>
<instruction> Dlg.detach = true;</instruction>
<instruction> Dlg.Show();</instruction>
<instruction> var listview = Dlg.Control("listview1");</instruction>
<instruction> listview.AddItem("Test 1");</instruction>
<instruction> listview.GetItemByName("Test 1").subitems(0) = "Test Sub 1.1";</instruction>
<instruction> listview.GetItemByName("Test 1").subitems(1) = "Test Sub 1.2";</instruction>
<instruction> listview.AddItem("Test 2");</instruction>
<instruction> listview.GetItemByName("Test 2").subitems(0) = "Test Sub 2.1";</instruction>
<instruction> listview.GetItemByName("Test 2").subitems(1) = "Test Sub 2.2";</instruction>
<instruction> while (true) {</instruction>
<instruction> var Msg = Dlg.GetMsg();</instruction>
<instruction> if (!Msg.result) break;</instruction>
<instruction> DOpus.Output("Msg Event = " + Msg.event);</instruction>
<instruction> if (Msg.event == "click" && Msg.control == "Autosize") {</instruction>
<instruction> listview.columns.AutoSize();</instruction>
<instruction> }</instruction>
<instruction> }</instruction>
<instruction> DOpus.Output("Return code = " + Dlg.result);</instruction>
<instruction>}</instruction>
<instruction>==SCRIPT RESOURCES</instruction>
<instruction><resources></instruction>
<instruction> <resource name="dialog1" type="dialog"></instruction>
<instruction> <dialog fontsize="8" height="114" lang="english" resize="yes" standard_buttons="cancel" width="150"></instruction>
<instruction> <control height="84" name="listview1" resize="wh" type="listview" viewmode="details" width="138" x="6" y="6"></instruction>
<instruction> <columns></instruction>
<instruction> <item text="Long Column Name 1" /></instruction>
<instruction> <item text="Long Column Name 2" /></instruction>
<instruction> <item text="Long Column Name 3" /></instruction>
<instruction> </columns></instruction>
<instruction> </control></instruction>
<instruction> <control height="14" name="Autosize" resize="y" title="Autosize" type="button" width="50" x="6" y="96" /></instruction>
<instruction> </dialog></instruction>
<instruction> </resource></instruction>
<instruction></resources></instruction>
</function>
</button>
Steve
May 19, 2020, 11:51am
5
I’ll do some more testing to see if I can narrow down what triggers it tomorrow.
Steve
May 19, 2020, 12:18pm
6
You might be on to something with it being related to scrolling - you can see it has happened to the third column on the screenshot of the Log Reader in my bulk meta script.
Steve
May 20, 2020, 4:17am
7
I can reproduce the problem with your example button. The first video shows the third column has not autosized correctly when I resize the dialog. It's resized for the column items rather than the title.
Could it be related to the 125% DPI I have to use on this laptop?
In the next video, it shows the same problem with no resizing of the lister and no scrolling. It's the third column again.
Leo
May 20, 2020, 11:38am
8
If it only happens with the last column then I know what that is. The way that works has been improved for the next beta.
Steve
May 20, 2020, 11:41am
9
Thanks.
In the second video it happens with the third of five columns, not the last though.
Leo
May 20, 2020, 11:52am
10
I can't get it to happen for any other columns.
Is the 2nd video using listview.columns.AutoSize();
or is it sizing/autosizing individual columns?
If you make the column name a much wider string, does it get wider then, or is it always the same size?
Steve
May 21, 2020, 3:37am
11
The 2nd video is using listview.columns.AutoSize();
The only thing I really do different to your example button above is to use dlg.Create(), populate the columns, then dlg.Show(). Changing that to just using dlg.Show() prior to populating seems to have no effect.
Had another thought - I am using dlg.LoadPosition();
to recall a stored lister size/position which differs from the == script resources
dimensions in the second video. This is done before the dlg.Create();
though.
Here's what I see when I give the column a wider string.
Leo
May 21, 2020, 8:12am
12
Thanks for trying that. I think I see what's wrong. The width is based on the header string, but it's off by a few pixels.
Some of the basic Windows font-rendering/measuring APIs have slightly different kerning these days (they used to all be consistent, then some clever person changed some of them but not others) and we must not be using the right one there.
1 Like
Leo
May 21, 2020, 11:55am
14
Turns out it wasn't kerning after all, but a more subtle DPI thing.
Got it fixed now, for the next beta.
Thanks again for the examples and testing!
1 Like
Steve
May 22, 2020, 1:29am
15
Confirmed that it's working fine here now with the latest beta. Thanks very much.
1 Like