[Lazarus] GetWindowSize misleading documentation or bug?
zeljko at holobit.net
Sat Sep 27 16:54:09 CEST 2014
On 09/27/2014 04:01 PM, Luca Olivetti wrote:
> 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);
> var f:TForm;
> wr: TRect;
> h: Integer;
> w: Integer;
> 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.
> Just FYI.
I know about it. It's explained at the mentioned link, also gtk2lcl puts
size events in queue and process it via Application.ProcessMessages, qt
provides such event when it's ready.
More information about the Lazarus