2013-10-17 18 views
0

我已經背景值,如果空

property Background: TPicture read FBackground write SetBackground; 

如果不曾經assiged它,將數值是背景是什麼?

我曾嘗試

if Background = NULL then 

begin 
... 
.. 
... 
end; 

回答

5

這要看情況。當在構造函數中創建的領域和FBackground分配,然後使用:

if FBackground.Graphic = nil then 

或者:

if not Assigned(FBackground.Graphic) then 

如果圖形分配,然後使用:

if FBackground.Graphic.Empty then 

如果屬性和字段都未分配ED然後使用:

if FBackground = nil then 

或者:

if not Assigned(FBackground) then 

上述所有組合:

if (FBackground = nil) or (FBackground.Graphic = nil) or FBackground.Graphic.Empty then