Board index » cppbuilder » c++ builder 3 help with components not showing.

c++ builder 3 help with components not showing.

Help! :)

My problem is that I'm trying to create a new TImage as needed in my
application, but it will not show.  What am I needing to do to get it to
show?

This code runs when a user clicks a button:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
TImage *SkillImage;
SkillImage = new TImage(Form1);
SkillImage->Picture->LoadFromFile("C:\\Pic.BMP");
SkillImage->Left = 14;
SkillImage->Top = LastTop + 20;
LastTop = SkillImage->Top'

Quote
}

LastTop is an Integer in Form1.h

What am I leaving out to get the Image to show.  I get no errors so I have
nothing to go on.

Thanks

 

Re:c++ builder 3 help with components not showing.


you need to set the Parent property.  The Parent is in charge of displaying the
component.  Also you should be using 'this' instead of Form1 as the
Owner/Parent.  Using singleton global variables inside a class method is not
good practice.

Quote
Sorwen wrote:

> Help! :)

> My problem is that I'm trying to create a new TImage as needed in my
> application, but it will not show.  What am I needing to do to get it to
> show?

> This code runs when a user clicks a button:

> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
> TImage *SkillImage;
> SkillImage = new TImage(Form1);
> SkillImage->Picture->LoadFromFile("C:\\Pic.BMP");
> SkillImage->Left = 14;
> SkillImage->Top = LastTop + 20;
> LastTop = SkillImage->Top'
> }

> LastTop is an Integer in Form1.h

> What am I leaving out to get the Image to show.  I get no errors so I have
> nothing to go on.

> Thanks

--
Jeff Overcash (TeamB)   I don't think there are any Russians
(Please do not email    And there ain't no Yanks
 me directly unless     Just corporate criminals
 asked.  Thank You)     Playing with tanks.  (Michael Been)

Re:c++ builder 3 help with components not showing.


Sorwen, try this and it will work.

TImage *SkillImage;
SkillImage = (new TImage(this));
SkillImage->Parent = Form1;

Quote
"Sorwen" <sor...@aol.com> wrote in message news:3b57703b$1_2@dnews...
> Help! :)

> My problem is that I'm trying to create a new TImage as needed in my
> application, but it will not show.  What am I needing to do to get it to
> show?

> This code runs when a user clicks a button:

> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
> TImage *SkillImage;
> SkillImage = new TImage(Form1);
> SkillImage->Picture->LoadFromFile("C:\\Pic.BMP");
> SkillImage->Left = 14;
> SkillImage->Top = LastTop + 20;
> LastTop = SkillImage->Top'
> }

> LastTop is an Integer in Form1.h

> What am I leaving out to get the Image to show.  I get no errors so I have
> nothing to go on.

> Thanks

Re:c++ builder 3 help with components not showing.


THANKS!!!
Quote
"Sorwen" <sor...@aol.com> wrote in message news:3b57703b$1_2@dnews...
> Help! :)

> My problem is that I'm trying to create a new TImage as needed in my
> application, but it will not show.  What am I needing to do to get it to
> show?

> This code runs when a user clicks a button:

> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
> TImage *SkillImage;
> SkillImage = new TImage(Form1);
> SkillImage->Picture->LoadFromFile("C:\\Pic.BMP");
> SkillImage->Left = 14;
> SkillImage->Top = LastTop + 20;
> LastTop = SkillImage->Top'
> }

> LastTop is an Integer in Form1.h

> What am I leaving out to get the Image to show.  I get no errors so I have
> nothing to go on.

> Thanks

Re:c++ builder 3 help with components not showing.


Thanks both.  I'll do that.  I've been ready to pull my hair out.  This will
make a big step in finally getting this to a more completed stage.  By the
way the LastTop doesn't really exist I was just using it as a sort of place
holder for another large process I have going on that as part of its
function would be to place the next image down from the last along with some
other stuff.

Thanks again,
Sorwen

Quote
"Sorwen" <sor...@aol.com> wrote in message news:3b57703b$1_2@dnews...
> Help! :)

> My problem is that I'm trying to create a new TImage as needed in my
> application, but it will not show.  What am I needing to do to get it to
> show?

> This code runs when a user clicks a button:

> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
> TImage *SkillImage;
> SkillImage = new TImage(Form1);
> SkillImage->Picture->LoadFromFile("C:\\Pic.BMP");
> SkillImage->Left = 14;
> SkillImage->Top = LastTop + 20;
> LastTop = SkillImage->Top'
> }

> LastTop is an Integer in Form1.h

> What am I leaving out to get the Image to show.  I get no errors so I have
> nothing to go on.

> Thanks

Other Threads