Hola Ernie,

When using BitmapFromFile I received quite often a 0 as return.
Calling GetLastError always returned "Path Not Found"

It works tho when I do this weird fix:

invoke BitmapFromFile, a$ szTempbuffer
cmp eax,0
jz @B

It always worked prefectly until I started calling BitmapFromFile in a pretty thight loop +/- 30 times.
Posted on 2002-08-18 16:29:51 by JimmyClif
A man walked into a doctor's office and said; "Doctor, it hurts when I bend my hand like this."

The Doctor said "Don't do that!"

BitmapFromFile returns ERROR_FILE_NOT_FOUND for any failure of OleLoadPicturePath. If you want to trace it down further you'll need to inspect the returned HRESULT inside the lib. Either messagebox it (which will slow the loop and probably prevent the error), or add an extra parameter to send it back to the calling routine.

Other then direct searching, my first guess would be to check if the matched CoInitialize and CoUninitialize calls are running a tad slow on another thread by 1) delete all of them from the ImageLib then 2) add them to your program code when the app starts (just CoInitialize) and finishes (just CoUninitialize).
Posted on 2002-08-18 18:41:09 by Ernie
Thanks Ernie !

Cutting out those two calls did the trick !

Operation successful, No more hands, no more pain!
Posted on 2002-08-19 18:05:12 by JimmyClif

thanks for letting me know that worked... and thanks for now leaving me with another dilemma <g>

I wrote those libs as black box wrappers for image loading, the intent to be a simple API-like set of commands one can apply without knowing the internals. That was mostly to hide any COM details, but once you start on that path it's best to complete it.

So... which sounds like a better plan:

1) Instruct users to include CoInitialize and CoUninitialize like you did, and delete them from the lib

2) Provide an ImageLibInit and ImageLibClose functions that are just wrappers for CoInitialize and CoUninitialize

3) some other brilliant, bullitproof user friendly idea.

Any suggestions?
Posted on 2002-08-19 20:49:38 by Ernie
Tough choice....

Considering that probably 50% never read any small print in documentation I'd go for number 2.

Let ImageLibInit set a Flag telling any of the Bitmap*** Functions if it's loaded or not, and hope the User will include ImageLibClose by himself; so at least if your not reading any docs the Flag will pop up a MsgBox telling you so :)

Even tho it's only a wrapper for a call with no arguments the <ah-ha> effect will be there if it's renamed corresponding to the ImageLib.

Or what about an:

ImageLibInit TEXTEQU <CoInitialize>
ImageLibClose TEXTEQU <CoUninitialize>

and hope the User will include it, screwing the Safety-Flag and blame it on the User not reading the docs in case of problems ?
Posted on 2002-08-20 07:14:51 by JimmyClif