Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How to know if the Imagebox is Empty or No picture loaded


This question is answered.


Permlink Replies: 3 - Last Post: Apr 9, 2018 10:03 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
roca robin

Posts: 140
Registered: 9/10/06
How to know if the Imagebox is Empty or No picture loaded  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 8, 2018 11:17 PM
if (Image1->Picture->Graphic==Null) don't work

in Delphi this works
if (image1.Picture.Graphic=nil) then
Alex Belo

Posts: 626
Registered: 10/8/06
Re: How to know if the Imagebox is Empty or No picture loaded [Edit]
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 1:39 AM   in response to: roca robin in response to: roca robin
roca robin wrote:

if (Image1->Picture->Graphic==Null) don't work

in Delphi this works
if (image1.Picture.Graphic=nil) then

"don't work" - what does it mean exactly?

--
Alex
Antonio Estevez

Posts: 665
Registered: 4/12/00
Re: How to know if the Imagebox is Empty or No picture loaded [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 2:00 AM   in response to: roca robin in response to: roca robin
El 09/04/2018 a las 08:35, roca robin escribió:
if (Image1->Picture->Graphic==Null) don't work

Is Null a typo? It should be NULL

if (Image1->Picture->Graphic==NULL)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: How to know if the Imagebox is Empty or No picture loaded [Edit]
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 10:03 AM   in response to: roca robin in response to: roca robin
roca robin wrote:

if (Image1->Picture->Graphic==Null) don't work

C++ is a case-sensitive language. Null is a variable of type Variant.
NULL is what you want instead:

if (Image1->Picture->Graphic == NULL)


Or, a safer way:

if (!Image1->Picture->Graphic)


Also, TGraphic has an Empty property:

if (!Image1->Picture->Graphic)
{
    // not loaded...
}
else if (Image1->Picture->Graphic->Empty)
{
    // loaded but empty...
}
else
{
    // ready...
}


Or, the other way around:

if ((Image1->Picture->Graphic) && (!Image1->Picture->Graphic->Empty))
{
    // ready...
}
else
{
    // not ready...
}


--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02