C++/VB - CListCtrl unnecessarily clips texts in Windows 7
Asked By Kjetil Viggen
18-Jan-10 08:22 AM

Hi All
My application uses the MFC control CListCtrl (in List mode) to display a
list of items. The control automatically orders items in columns, where the
column width is determined by the longest text.
This works well on Windows XP and Vista, but fails on Windows 7. A long text
may be correctly displayed, while a short text in the same column may get
clipped. Usually the last couple of letters will be missing, and replaced by
easily reproduced in a simple MFC test application.
Examples:
I have only seen the problem for texts containing capital letters. Texts
containing L, V and A seem especially error prone.
The problem only occurs for specific fonts. Texts get clipped if I use
Arial, Calibri or Times New Roman, while when using Arial Black, Georgia or
MS Sans Serif all texts are correctly displayed. So changing font could be a
workaround, but as all the rest of the UI uses Arial I would rather not do
this.
Does anyone have a clue what is going on here, and even better - how to fix
it?
Regards,
Kjetil
Windows XP
(1)
Windows 7
(1)
Vista
(1)
CListCtrl
(1)
LeslieAppreciate
(1)
Calibri
(1)
Georgia
(1)
Arial
(1)
Leslie Milburn replied to Kjetil Viggen
This occurs when the column is not wide enough. Naturally different fonts
and using caps changes what can fit into the column. The solution is to make
the column wider. If I remember correctly, there is a function call to get
windows to autosize the columns itself but this would need to be done after
the list has been populated.
hth
Leslie.
Kjetil Viggen replied to Leslie Milburn
Hi Leslie
Appreciate your reply, however it does not solve my problem.
I am well aware that texts get clipped in CListCtrl when a column is not
wide enough to accomodate the text. This is not the problem here.
I can resize my CListCtrl so that all my text entries are shown in a single
column.
The text "THOUSANDS OF CHAIRS" is then unclipped, i.e. the CListCtrl has
autosized the column to make room for this 19 characters long text.
The same column should display the text "LAV". This is however clipped, and
displayed as "L...". As the column has enough space to fit "THOUSANDS OF
CHAIRS", it should definitely also be able to display "LAV" without clipping.
Exactly the same code gives no clipping on XP and Vista, and this seems to
be a clear indication that there is a Windows 7 specific bug in some text
length calculation used by CListCtrl.
Kjetil
Kjetil Viggen replied to Kjetil Viggen
NB:
The problem only occurs in List view mode (LVS_LIST). When using Report view
mode (LVS_REPORT) the texts are correctly clipped according to column width.
Kjetil
Kjetil Viggen replied to Kjetil Viggen
Just to wrap this up:
I ended up unhappily doing a hack - changing the font in the CListCtrl from
Arial to MS Sans Serif. With this font no clipping occurs.
Seems like CListCtrl uses different algorithms for calculating the needed
field width for a text and for checking if a text is to wide to fit a given
field:
Step 1: Calculate needed field width for a given text.
Step 2: Clip the text if it is too long to fit a given field width.
The problem is most likely related to font kerning, as it was only observed
for capital letters, and specifically for letter commands like LV and AV.
Kjetil

B#0H-"@T*#0H-"DQ01#-$6$U%4T@@(" @(" @ M(" @(" @(& = ?<$UE<V@@(" @(" @(" @ / 2!.54Q, .R O+R! / = 7(@;65S:"!O M8FIE8W0@:6X@<WES;65M#0I$, T1-051%4DE!3#DJ(" @(" @(" @("!G7W!- M97-H36%T97)I86QS(#T@3E5, 3#L@+R \ @36%T97)I86QS(&9O<B!O = 7(@;65S M: T*3%!$25)%0U0S1%1%6%154D4Y*B @(" @9U]P365S:%1E> '1U<F5S(" ] M($Y53$P O(%1E> '1U<F5S(&9O<B!O = 7(@;65S: T*1% = / 4D0@(" @(" @ M(" @(" @(" @(" @9U]D = TYU;4UA = &5R:6%L<R ](#!, .R @(" \ O($YU W)M871S('1H870@9&]N)W0@ M<W5P<&]R = "!A;'!H82!B;&5N9&EN9PT*(" @($E$:7)E8W0S1#DJ('!$, T0@ M / 2!$6%541V5T1#-$.4]B:F5C = "@I.R -"B @("!I9B@@1D%)3 2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM#0HO+R!"969O<F4@82!D979I M8V4@:7, @8W)E871E9"P@;6]D:69Y('1H92!D979I8V4@<V5T = &EN9W, @87, @ M;F5E9&5D#0HO 2TM+2TM+0T*2%)%4U5, 5"!# M04Q, 0D%#2R! / ;D0S1#E#<F5A = &5$979I8V4H($E$:7)E8W0S1$1E = FEC93DJ M('!D, V1$979I8V4L(&-O;G-T($0S1%-54D9!0T5?1$530RH@<$)A8VM" = 69F M97)3 = 7)F86-E1&5S8RP@ = F]I9"H@<%5S97)#;VYT97AT("D-"GL-"B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 9Y / -*7-;W = QD6BZH = M0GF4744JHN = F / WBG<1G(`&PXX[ \ UFW6M6]GK^H1:IJ-U! "@@2)V 'R
developer of an application that receives messages over TCP / IP. This application works okay under XP, however under Vista there is a network 'RST' approximately every 24 hours on average. Using Wireshark to see confirming this with identical hardware. Could there be an issue with the TCP stack in Vista? So here is some technical detail. Below are some excerpts from wireshark traces. First. . . here is what the traffic looks like normally, the PC (10.99.7.251) regularly received 30 bytes of data from the device (10.99 7.28). The PC responds with a taxi (1 byte of data to circumvent Nagels) - then the device acknowledges it. 193139 2008-03-11 16:12:07.809202 10.99.7.28 10.99.7.251 TCP 7418 > 50598 [PSH, ACK] Seq = 1440478 Ack = 48371 Win = 8192 Len = 30 193140 2008-03-11 16:12:07.809346 10.99.7.251 10.99.7.28 TCP 50598 > 7418 [PSH, ACK] Seq = 48371 Ack = 1440508 Win
C++ / VB script for windows 7 doesn't work Hi, In a Windows 2003 AD, we use a script to map network drives and printers, and also to disable windows firewall in our windows XP clients. Now we had started to use windows 7 in our clients, and problems came with that script. I tryed to find out which
C++ / VB Problem with XP scheduler? I am having firefox 3.5.5 and 3.5.6 freeze my box when I update several tabs in a rapid succession on Win XP SP3. What happens is box totally freezes. Task manager -> Performance tab shows one of cores ctl-alt-del) and disk stops flashing every few seconds as it normally does under XP. Interestingly enough, it does not happen under Windows 7 on the same box no matter how hard I try. Some say it is a problem with crappy XP scheduler. Is there anything I can do under XP to fix this issue? Hardware: Asus M4A78 motherboard, Athlon 2, X4 620 CPU, 4 Gigs of DDR2 ram by Team Extreme. Running on Windows XP SP3. - - Programmer's Goldmine collections: http: / / preciseinfo.org I'd say it is a