Re: Analyze This

new topic     » goto parent     » topic index » view thread      » older message » newer message

Continueing on this thread. I've discovered that win32lib getFontSize is wrong
..at least in my opinion. Look at this link which has a drawing of characters.

http://msdn2.microsoft.com/en-us/library/ms534015.aspx

Then look at the winlib32 code below. "tmInternalLeading" is actually added
twice
for the character heigth. I think that "tmInternalLeading" should be removed
from the char heigth. I've rem'd it out and my list boxes have the correct
height
since I'm sizing them by character heights. If I'm wrong please explain.

global function getFontSize( integer id )

    -- get metrics for current font

    integer width, height, maxwidth
    atom tm

    -- text metric structure
    tm  = w32acquire_mem(0, SIZEOF_TEXTMETRIC )

    -- get the metrics of the font (queryFont will prepend the DC)
    if not queryFont( id, xGetTextMetrics, {tm} ) then
        warnErr( Err_GETFONTSIZE )
    end if

    -- assign values
    width   = w32fetch(tm,tmAveCharWidth)
    maxwidth   = w32fetch(tm,tmMaxCharWidth)
    height  = w32fetch(tm,tmHeight) +
                w32fetch(tm,tmInternalLeading) + <----------- remove this 
                w32fetch(tm,tmExternalLeading)

    -- release
    w32release_mem( tm )

    -- return results
    return { width, height, maxwidth }

end function



George Walters wrote:
> 
> Can someone explain to me why the list box on a bound/shrouded program is
> a difference vertical length than when not bound/shrouded? When bound it
> contains 11 rows of items and not bound it has 10 rows of items. Here's the
> statement which creates the list box. Using win32 by the way.
> 
> }}}
<eucode>
> constant    idList = create(List,"",Main,4,cy*19-tint(cy/2),
>                            cx*80+4,cy*10,WS_SCROLLBARS)
> </eucode>
{{{

> 
> The 'cy*10' should set the number of rows to 10 which it does when not 
> bound. 'cy' is the vertical height of a character as returned by the
> function getFontSize.
> 
> }}}
<eucode>
>     setFont(Screen, "Courier New", fs, Normal)
>     charSize = getFontSize(Screen)
> 
>     cx = charSize[1]
>     cy = charSize[2]
> 
> </eucode>
{{{

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu