[Lazarus] GetWindowSize misleading documentation or bug?

Luca Olivetti luca at wetron.es
Sat Sep 27 12:09:08 CEST 2014

El 27/09/14 00:05, Giuliano Colla ha escrit:
> Il 26/09/2014 22:47, Luca Olivetti ha scritto:
>> El 26/09/14 22:45, Luca Olivetti ha escrit:
>>> Strange, on mageia 4, kde, lazarus 1.2.4 it doesn't work. What I'm
>>> trying to do is to tile windows one next to the other. Using
>>> GetWindowRect under windows I can do it properly, while on linux gtk the
>>> windows overlap (i.e. with this layout
>>>       A  B  C
>>>       D  E
>>> A overlaps D and B overlaps E, the amount of overlap seems to be equal
>>> to the height of the title bar).
>> Oh, and there's also a slight overlap between A-B, B-C and D-E
> Something which could affect your results is the timing. The window
> manager takes a time to add the decorations. Different window managers
> take different time. It's meant for human observers, which don't
> perceive a delay of some tens of milliseconds. Therefore it's given a
> low priority (and the mechanism is quite different from Windows to
> Linux). If you ask the size too early, you get a size which has not yet
> been adjusted.
> You may verify if the function works properly by adding somewhere in
> your form a button and a label, and with the onClick of the button write
> in the label caption both the result of GetWindowSize and of
> GetWindowRect. You can't possibly push the button faster than the time
> it takes the window manager to decorate your window!

I'm puzzled: with a test program I see no difference in the size in both
cases (right after showing the form and after pressing the button) *and*
the size is the right one (in FormShow is always 1,1 btw).
I must be doing something else wrong (though the tiling is the correct
on under windows, mmmh..).
Oh, well, this program has to work in windows only, so I'll just
consider it a documentation error and go on with my life ;-)

Luca Olivetti
Wetron Automation Technology http://www.wetron.es
Tel. +34 935883004  Fax +34 935883007

More information about the Lazarus mailing list