2012-08-03 15 views

回答

10

如果你有一個現代的Delphi,那麼這個代碼就可以編譯和工作。現代Delphi版本中的TRect利用運算符重載來重載相等運算符。由於Delphi記錄中沒有內置的相等運算符,因此您無法在Delphi 7中使用該語法。

沒有編譯器的幫助,你需要一個輔助函數。你可以寫你自己:

function EqualRect(const r1, r2: TRect): Boolean; 
begin 
    Result := (r1.Left=r2.Left) and (r1.Right=r2.Right) and 
      (r1.Top=r2.Top) and (r1.Bottom=r2.Bottom); 
end; 

雖然,作爲@Sertac指出,還有一點需要編寫自己的EqualRect時,你可以使用Windows API function of the same name

+8

..或使用'windows.EqualRect'。 – 2012-08-03 13:53:51