Archived

This topic is now archived and is closed to further replies.

Opening a picture file in C/C++

This topic is 5021 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, I''m using Borland C++ Builder 4 IDE. I want to load a picture file onto a form at run time - What is the code to do this ? Thank you for your time

Share this post


Link to post
Share on other sites
I have no idea of the code, though I done it before...

Put a TBitmap object pointer in your form class, heres the basic idea:


class MyForm : public TForm
{
...
TBitmap *pBitMap;
...
};

...
MyForm::MyForm(...)
{
pBitMap = 0;
}
...
// OnCreate or Onload, whatever its called
MyForm::OnLoad(...)
{
pBitMap = new TBitmap([path to file]); //
// You might need to call a function to load the image

// mess around with properties to show, position,
// ie Code similar in similar format to pBitMap->Pos(x, y)
//pBitMap->Show(); // I think this shows a control
}


MyForm::~MyForm(..)
{
delete(pBitMap)
}
...


Hope this helps, its fairly straight forward,

Keith

Share this post


Link to post
Share on other sites