There's a TImage component on a form in my program.
In some situation, the program must test:
If "there is an image assigned to the picture property of the TImage component" then ...
How can I do this?
There's a TImage component on a form in my program.
In some situation, the program must test:
If "there is an image assigned to the picture property of the TImage component" then ...
How can I do this?
if Image1.Picture.Graphic = NIL
then ShowMessage("There is no image.")
else ShowMessage("Image found.");
If working with bitmaps, you can also do this:
if Image.Picture.Bitmap.Empty then ShowMessage("There is no spoon");
Better late than never!
The right way is:
if Assigned(Image1.Picture.Graphic) then ...
You don't say, but I'll assume you're talking about Delphi.
You can check whether there's a bitmap in the TImage control by testing:
if Image.Picture.Bitmap.Width > 0 then
// do whatever