Page 1 of 1

Difference in execution between IDE and EXE

Posted: Tue Jun 19, 2007 1:19 pm
by drahneir
Hello,

in my application I printout some data from a database on a printer. Additionally there are 2 images which should also be printed.
When I run the exe file, evererything is printed except the images. When I start the program from the IDE, all inclusive the images is printed.

Code: Select all

     UseTIFFImageDecoder()
     LoadImage(#Image_0, "XXX.tif")
     LoadImage(#Image_1, "YYY.tif")
     .
     ResizeImage(#Image_0, 120, 280)
     ResizeImage(#Image_1, 200, 200)
     .
     DrawImage(ImageID(#Image_0), x0, y0)
     DrawImage(ImageID(#Image_1), x1, y1)
What is the reason for this different behaviour?

Regards

Posted: Tue Jun 19, 2007 1:32 pm
by Trond
Maybe the images can't be loaded if the current directory is different?

Posted: Tue Jun 19, 2007 1:33 pm
by Fred
Any chance to have a small working snippet showing the problem ?

Posted: Tue Jun 19, 2007 3:47 pm
by omit59
@drahneir

I had same of kind problem today, dont know if it has got anything to do with yours?

My program (made with PB) was moved to another computer which has NT4 system, and at the same time printing pictures was stopped, everything else prints ok, just pictures are missing.

Tried using drawimage and API StretchBlt, but neither prints pictures.
I have no idea what to do...

So anybody any tips?

Timo

Posted: Tue Jun 19, 2007 5:36 pm
by drahneir
Hello,

@ Trond: the PB files, the .exe file and the images are all in the same directory.


@ Fred: I will see, what I can do.

Posted: Tue Jun 19, 2007 5:55 pm
by drahneir
Gentlemen,

the problem isn't a problem any more. Thanks Trond, who mentioned the directory, I put in the full path of the image files into the LoadImage() commands, and now it works as it should do.
I didn' put in the full path before, because it is somewhat lengthy and, as I wrote before, it worked when I tested it from the IDE.
Thanks for your help.


Regards

Posted: Tue Jun 19, 2007 5:56 pm
by Trond
drahneir wrote:Hello,
@ Trond: the PB files, the .exe file and the images are all in the same directory.
Exactly. The current directory has nothing to do with the executable directory. It could be something completely different, and then loading the images will fail, because all paths are relative to the current directory (not the exe directory).

Posted: Tue Jun 19, 2007 6:08 pm
by ts-soft

Code: Select all

GetPathPart(ProgramFilename())
or API GetModuleFileName works only with the exe, not in the IDE.
If you only compile in the IDE (no exe-creation) you should use this:

Code: Select all

GetCurrentDirectory()
The PBCompiler sets the correkt Path for this function.