Board index » cppbuilder » Using TOpenDialog LoadFromFile() and TImage Picture LoadFromFile()

Using TOpenDialog LoadFromFile() and TImage Picture LoadFromFile()

I am creating an application that uses both the TImage Picture LoadfromFile()
and
the TOpenDialog LoadFromFile() functions. The  bitmaps load fine until I use
the
OpenDialog function.
Since I was using the Applications directory as the working directory, when I
called the Image->Picture->LoadFromFile(), I used string
("bitmaps//filename.bmp") to load file. Once I used the OpenDialog LoadFromFile
-- this no longer worked. What I did to correct the problem was to replace the
Picture->LoadFromFile argument with
"C:\\ApplicationDirectory\\bitmaps\\filename.bmp" . It works fine now. What I
want to know is why does the LoadFromFile() function of OpenDialog causes this
problem.
I  appreciate and Thank You in advance.
 

Re:Using TOpenDialog LoadFromFile() and TImage Picture LoadFromFile()


i think the normal topendialog component has no loadfromfile function! if
you use the loadfromfile function of image->picture with the filename
"bitmaps//filename.bmp" it will look in the working directory! not changed
it is the directory were you started the app and will work.
if you want to use a opendialog and have selected a bitmap, it contain the
full path to that bitmap. its the save way!

if (opendialog->execute())
{
    image->picture->loadfromfile(opendialog->filename);

Quote
}

if you always have a directory bitmaps in your app directory from were you
want to load bitmaps at runtime, you can use application->exename which will
contains the full path were you have started the app and the exe name it
self. if you use

image->picture->loadfromfile(extractfilepath(application->exename)+"bitmaps\
\filename.bmp");

you can load any bitmap at runtime from the bitmaps directory. and doesn't
matter if the working directory has changed!

hope it helped! :)

"Rk1954" <rk1...@aol.com> schrieb im Newsbeitrag
news:20020320130622.17042.00002108@mb-fr.aol.com...

Quote
> I am creating an application that uses both the TImage Picture
LoadfromFile()
> and
> the TOpenDialog LoadFromFile() functions. The  bitmaps load fine until I
use
> the
> OpenDialog function.
> Since I was using the Applications directory as the working directory,
when I
> called the Image->Picture->LoadFromFile(), I used string
> ("bitmaps//filename.bmp") to load file. Once I used the OpenDialog
LoadFromFile
> -- this no longer worked. What I did to correct the problem was to replace
the
> Picture->LoadFromFile argument with
> "C:\\ApplicationDirectory\\bitmaps\\filename.bmp" . It works fine now.
What I
> want to know is why does the LoadFromFile() function of OpenDialog causes
this
> problem.
> I  appreciate and Thank You in advance.

Other Threads