[Lazarus] Qt Ws doesn't support properly GetWindowSize() and GetWindowRect()

zeljko zeljko at holobit.net
Fri Dec 15 18:23:38 CET 2017


On 15.12.2017 17:08, Giuliano Colla via Lazarus wrote:
> This snippet of code, which executes as expected with GTK2 WS, fails 
> with QT WS:
> 
>> procedure TForm1.btnWsizeClick(Sender: TObject);
>> var  aHandle: THandle;
>>    aWidth,aHeight: Integer;
>>    aRect: TRect;
>> begin
>>    aHandle:= Form1.Handle;
>>    if GetWindowSize(aHandle,aWidth,aHeight) then begin
>>      Label3.Caption:= Format('Width: %d Height: %d',[aWidth,aHeight]);
>>    end
>>    else Label3.Caption:= 'Failed to get Window Size';
>>    GetWindowRect(aHandle,aRect);
>>    Label3.Caption:= Label3.Caption + Format(' Rect: %d,%d',[
>>    aRect.Right-aRect.Left,
>>    aRect.Bottom-aRect.Top]);
>>    Label3.Visible:= True;
>> end;
> 
> As it is, it crashes with an AV in the GetWindowSize call. The failing 
> call is in TQtWidget.GetWidget: it executes Result := 
> QWidgetH(TheObject) where TheObject appears to have taken a bogus value.
> 
> If I remove the offending call, then the subsequent GetWindowRect() 
> returns bogus values, sort of -32704 and -85984614 instead of 689 and 522.
> 
> Under GTK2 both calls work as expected.
> 
> Tested under Linux x86_64 (CentOs 6) with Lazarus 1.8 - QT45 - fpc 3.0.4
> 
> It doesn't appear to be a regression, because it does the same even with 
> a very old Lazarus 1.2.6 , qt45 and fpc 2.6.4
> 
> Should I report a bug or is it a known issue?

Of course, please do so, also attach example.

zeljko


More information about the Lazarus mailing list