在我的程序中,表单上有一个 TImage 组件。
在某些情况下,程序必须测试:
如果“有一个图像分配给 TImage 组件的图片属性”,那么......
我怎样才能做到这一点?
在我的程序中,表单上有一个 TImage 组件。
在某些情况下,程序必须测试:
如果“有一个图像分配给 TImage 组件的图片属性”,那么......
我怎样才能做到这一点?
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");
迟到总比不到好!
正确的方法是:
if Assigned(Image1.Picture.Graphic) then ...
你没有说,但我假设你在谈论德尔福。
您可以通过测试检查TImage控件中是否有位图:
if Image.Picture.Bitmap.Width > 0 then
// do whatever