background value if empty

只谈情不闲聊 提交于 2019-12-11 20:12:26

问题


I have

property Background: TPicture read FBackground write SetBackground;

if nothing is ever assiged to it, what would the value be of background?

i have tried

if Background = NULL  then

begin
...
..
...
end;

回答1:


It depends. When the field is created in the constructor and FBackground is assigned, then use:

if FBackground.Graphic = nil then

Or:

if not Assigned(FBackground.Graphic) then

If the Graphic is assigned, then use:

if FBackground.Graphic.Empty then

And if both property and field are unassigned then use:

if FBackground = nil then

Or:

if not Assigned(FBackground) then

All of the above combined:

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


来源:https://stackoverflow.com/questions/19439202/background-value-if-empty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!