INTERACT FORUM
Windows => Plug-in Development => Topic started by: aseiden on December 18, 2004, 02:28:22 pm
-
Hi folks,
I have what's probably a dumb newbie question about trying to load an album thumbnail in VS C++. I'm trying to use the following code, which is based on the CImage docs that MicroSoft provides:
// get imagefile name from MJ
_bstr_t thumbnailfile = album->GetImageFile(IMAGEFILE_THUMBNAIL_MEDIUM);
// Load thumbnail
CImage thumb;
HRESULT hr = thumb.Load(thumbnailfile);
CBitmap* pBitmap = CBitmap::FromHandle(thumb.m_hBitmap);
but this won't even compile--I get an error that complains that the in the last line, m_hBitmap is a private member of CImage. But this is the way the MS samples show to use CImages with CBitmaps, which are needed for controls, etc, so I'm confused!
I'm an experienced C programmer, but I'm new to Windows, C++, and MC programming. I'm trying to teach myself all of those things on this project, so my apologies if my questions are stupid.
Any help appreciated--either as to what I'm doing wrong or if there is an alternate way of doing this better. (Of course, if JR would like to expose their JRImage methods, that would be great, too!)
thanks very much!
--Alex
-
Maybe OleLoadPicturePath would meet your requirements:
// Get the thumbnail filename
_bstr_t thumbnailfile = album->GetImageFile( IMAGEFILE_THUMBNAIL_MEDIUM );
// Load the picture
IPicture* picture;
::OleLoadPicturePath( thumbnailfile, NULL, 0, 0, IID_IPicture, (LPVOID*)&picture )
// Get the HBITMAP
HBITMAP hBitmap;
picture->get_Handle( (OLE_HANDLE*)&hBitmap );
// Free the picture
picture->Release();
Note that error checking has been exlcuded for brevity. Also when you get the HBITMAP you can load it into a CBitmap if you really need to.
-
Thanks, Rhino! Your code works--now I have to make my CImageList stuff play nicely with it.
Cheers,
Alex