[Lazarus] GetWindowSize misleading documentation or bug?
luca at wetron.es
Sat Sep 27 16:01:18 CEST 2014
El 27/09/14 14:32, zeljko ha escrit:
> On 09/27/2014 12:26 PM, Luca Olivetti wrote:
>> El 27/09/14 12:23, Luca Olivetti ha escrit:
>>> El 27/09/14 12:09, Luca Olivetti ha escrit:
>>>> I'm puzzled: with a test program I see no difference in the size in
>>>> cases (right after showing the form and after pressing the button)
>>>> 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..).
>>> Found it, nothing wrong on my part: the test program used an auto
>>> created form, the real application creates the form at run time *and*
>>> right after creating the form, after the show GetWindowRect only returns
>>> the client size. I have to introduce a delay for it to return the whole
>>> window's size (and even then, from time to time, it only returns the
>>> client size), so you were correct and this is insane.
>> And, for the record, with qt it's the same (only it seems the delay have
>> to be bigger).
> Under X11 nobody knows exact window size (except client size setted up
> by LCL or widgetset) until window is decorated by wm (read mapped -
> shown on screen). See
Yes, I understand, the "insanity" I referred to was about the underlying
environment, not Lazarus.
Anyway, I tried with this snipped of code to measure the decoration
procedure TForm1.Button1Click(Sender: TObject);
while true do
if (w<>f.width) and (h<>f.height) then
if i>1000 then
Label1.Caption:=format('%d w:%d h:%d',[i,w-f.width,h-f.height]);
The f.top and f.left assignment was a (futile) attempt to avoid flashing
the form on screen.
With gtk2 2 I consistently get the result at the first iteration (i=0),
while with qt it takes at least 2 cycles, on occasions i counted up to 20.
Wetron Automation Technology http://www.wetron.es
Tel. +34 935883004 Fax +34 935883007
More information about the Lazarus