ListBox: Fix LB_SETTABSTOPS (Resend)

Robert Shearman rob at codeweavers.com
Sun Jul 10 18:13:23 CDT 2005


Alexandre Julliard wrote:

>Robert Shearman <rob at codeweavers.com> writes:
>  
>
>>@@ -1277,12 +1286,14 @@ static INT LISTBOX_SetFont( LB_DESCR *de
>>         return 16;
>>     }
>>     if (font) oldFont = SelectObject( hdc, font );
>>-    GetTextMetricsW( hdc, &tm );
>>+    GetTextExtentPointA( hdc, alphabet, 52, &sz);
>>     if (oldFont) SelectObject( hdc, oldFont );
>>     ReleaseDC( descr->self, hdc );
>>+
>>+    descr->avg_char_width = (sz.cx / 26 + 1) / 2;
>>     if (!IS_OWNERDRAW(descr))
>>-        LISTBOX_SetItemHeight( descr, 0, tm.tmHeight, FALSE );
>>-    return tm.tmHeight;
>>+        LISTBOX_SetItemHeight( descr, 0, sz.cy, FALSE );
>>+    return sz.cy;
>>    
>>
>
>I think tm.tmHeight is a better choice for the height. Do you have
>evidence that Windows doesn't use the font metrics here?
>

In practice, tm.tmHeight and sz.cy are exactly the same, but it stands 
to reason that you might as well take the maximum height along with the 
average character width of the sample characters. On Windows, the 
calculation is done in GdiGetCharDimensions which returns a height 
parameter in addition to the normal text metrics. I'll be moving this 
calculation and the one for dialogs over to using this function in a 
future patch anyway.

-- 
Rob Shearman




More information about the wine-devel mailing list