In another thread you mentioned something about an updated Ipicture tutorial? I tried to E-mail you but it may not have gotten through. Can we see the new code please please please?:cool:
Posted on 2002-02-27 22:41:46 by The Worrier King
I didn't update the tut yet, so just take the orgional tut and delete the LoadPictureFile procedure, and replace the call to it with:

invoke OleLoadPicturePath, ADDR wsPicFileName, NULL, NULL, NULL, /
ADDR IID_IPicture, ADDR gpPicture1

Seems MS got smart and made an API to do what everyone would be doing anyway.
Posted on 2002-03-02 00:46:05 by Ernie
Okay, makin' progress here.

I tried using OleLoadPicturePath but it always returned E_FAIL, so there must be more to converting the tutorial than just replacing LoadPictureFile with OleLoadPicturePath.

However, I had good luck using LoadPictureFile itself. I managed to load DIBs and GIFs (transparent GIFs too), just like I wanted to. :alright:

So what else is necessary to use OleLoadPicturePath?:confused:
Posted on 2002-03-04 14:28:05 by The Worrier King
What's probably the problem is the wsPicFileName parameter, as that little 'w' in the name stands for "W I D E" and means its a Unicode string.

One way to convert ASCII to Unicode is thru the MultiByteToWideChar API:

int MultiByteToWideChar(
UINT CodePage, // code page (use CP_ACP)
DWORD dwFlags, // character-type options
LPCSTR lpMultiByteStr, // address of string to map
int cchMultiByte, // number of bytes in string
LPWSTR lpWideCharStr, // address of wide-character buffer
int cchWideChar // size of buffer

Since I tend to be simple minded, I made some macros to help me out here:

Ascii2Unicode MACRO pwszReturnBuf:REQ, pszSourceBuf:REQ, SizeOfSourceBuf:REQ
invoke MultiByteToWideChar, CP_ACP, 0, pszSourceBuf, -1, pwszReturnBuf, SizeOfSourceBuf
Unicode2Ascii MACRO pszReturnBuf:REQ, pwszSourceBuf:REQ, SizeOfSourceBuf:REQ
invoke WideCharToMultiByte, CP_ACP, 0, pwszSourceBuf, -1, pszReturnBuf, SizeOfSourceBuf, NULL, NULL
Posted on 2002-03-04 19:29:53 by Ernie
Just some notes for future reference.

First, cchWideChar should get the size of the destination buffer, not the source.

Also OleLoadPicturePath requires a full path in wsPicFileName, not a relative one.
Posted on 2002-03-05 22:30:10 by The Worrier King