Re: getClientRect

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

----- Original Message -----
From: "C. K. Lester" <cklester at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Subject: Re: getClientRect


>
> > > getClientRect ( integer ControlId )
> > > Get uncovered portion of the client area.
> > > Returns: { x1, y1, x2, y2 }
> > >
> > > If I not mistaken, it should be
> > > {x, y, width, height} ??
> > >
> >
> > Actually that turns out not to be the case. This routine returns {Left,
> Top,
> > Right, Bottom} coordinates. Not the way I'd do it but that's Windows for
> > you.
> >
> > Actually, I'll enhance the return value so it returns {Left, Top, Right,
> > Bottom, Width, Height}.
>
> Isn't that redundant? Why not make the user figure the Width and Height? I
> know it's very very few cycles to do the calculation in the library, but
> redundancy or duplicity doesn't seem right to me. :)
>
> I'm just wondering what your reasoning was... not complaining!!!

Sure! Nearly every use of getClientRect() is done to get the dimensions of
the client area rather than the coordinates of the bottom-right corner. This
means that people are generally doing this sort of thing...

    r = getClientRect(x)
    w = r[3]-r[1]
    h = r[4]-r[2]
    . . .

So all I'm doing now is doing these two subtractions for the caller. As you
say, it is a tiny use of the computing cycles available but it reduces that
amount of code to maintain in your program.

Win32lib is doing many redundant things, depending on your criteria. But
that is the very point of its existance. It does these things to make coding
you application easier. It is not trying to make your program run as fast as
it possibly can. The library is not about "making the user do ...", instead
it tries to do things so the user doesn't have to.

----------------
cheers,
Derek Parnell

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

Search



Quick Links

User menu

Not signed in.

Misc Menu