Y
Yan Yang
Guest
I am trying to display a GIF image in a static control. The GIF image is loaded using GDI+, it needs the image filename passed to the image construction, I want to obtain the filename from the resource ID, but I could not get it from the code below.
Any suggestion would be appreciated.
HBITMAP ctrlBitmap(NULL);
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
LPCTSTR lpszResourceName = MAKEINTRESOURCE(IDB_THICKNESSXY);
ASSERT(lpszResourceName != NULL);
HINSTANCE hInst = AfxFindResourceHandle(lpszResourceName, RT_RCDATA);
HRSRC hResInfo = ::FindResource(hInst, lpszResourceName, RT_RCDATA);
HGLOBAL hResData = ::LoadResource(hInst, hResInfo);
char* data = (char*):LockResource(hResData));
DWORD len = ::SizeofResource(NULL, hResInfo);
CString filename(data, len);
Gdiplus::Bitmap* bitmap = new Gdiplus::Bitmap(filename);
Gdiplus::Status status = bitmap->GetHBITMAP(NULL, &ctrlBitmap);
Gdiplus::GdiplusShutdown(gdiplusToken);
GetParent()->GetPropertySheet()->SetControlImage(ctrlBitmap);
Continue reading...
Any suggestion would be appreciated.
HBITMAP ctrlBitmap(NULL);
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
LPCTSTR lpszResourceName = MAKEINTRESOURCE(IDB_THICKNESSXY);
ASSERT(lpszResourceName != NULL);
HINSTANCE hInst = AfxFindResourceHandle(lpszResourceName, RT_RCDATA);
HRSRC hResInfo = ::FindResource(hInst, lpszResourceName, RT_RCDATA);
HGLOBAL hResData = ::LoadResource(hInst, hResInfo);
char* data = (char*):LockResource(hResData));
DWORD len = ::SizeofResource(NULL, hResInfo);
CString filename(data, len);
Gdiplus::Bitmap* bitmap = new Gdiplus::Bitmap(filename);
Gdiplus::Status status = bitmap->GetHBITMAP(NULL, &ctrlBitmap);
Gdiplus::GdiplusShutdown(gdiplusToken);
GetParent()->GetPropertySheet()->SetControlImage(ctrlBitmap);
Continue reading...