4

在我的程序中,表单上有一个 TImage 组件。

在某些情况下,程序必须测试:

如果“有一个图像分配给 TImage 组件的图片属性”,那么......

我怎样才能做到这一点?

4

3 回答 3

3
if Image1.Picture.Graphic = NIL 
then ShowMessage("There is no image.")
else ShowMessage("Image found.");

如果使用位图,您也可以这样做:

if Image.Picture.Bitmap.Empty then ShowMessage("There is no spoon");
于 2011-07-13T17:42:56.223 回答
2

迟到总比不到好!
正确的方法是:

if Assigned(Image1.Picture.Graphic) then ...

于 2015-02-06T22:43:39.673 回答
0

你没有说,但我假设你在谈论德尔福。

您可以通过测试检查TImage控件中是否有位图:

if Image.Picture.Bitmap.Width > 0 then
  // do whatever
于 2010-06-23T08:00:49.243 回答