ImageType::ImageType(const unsigned id, const CMString& file, IStream* pStream) : ImageBase(id) { m_bmp = NULL; m_pPropertyItem = NULL; m_nCurrentFrame = 0; m_nFrameCount = 0; if (!InitGdiPlus()) return; if (pStream) m_bmp = new Gdiplus::Bitmap(pStream); else m_bmp = new Gdiplus::Bitmap(T2W_SM(file.c_str())); if (m_bmp->GetLastStatus() != Gdiplus::Ok) { delete m_bmp; m_bmp = NULL; return; } GUID pageGuid = Gdiplus::FrameDimensionTime; m_nFrameCount = m_bmp->GetFrameCount(&pageGuid); if (IsAnimated()) { int nSize = m_bmp->GetPropertyItemSize(PropertyTagFrameDelay); m_pPropertyItem = (Gdiplus::PropertyItem*) new char[nSize]; m_bmp->GetPropertyItem(PropertyTagFrameDelay, nSize, m_pPropertyItem); } }
ImageType::ImageType(const unsigned id, const CMString& file, const int index, const IcoTypeEnum type) : ImageBase(id) { m_bmp = NULL; m_pPropertyItem = NULL; m_nCurrentFrame = 0; m_nFrameCount = 0; if (!InitGdiPlus()) return; switch (type) { case icoDll: { const HMODULE hModule = LoadDll(file); if (hModule != NULL) { HICON hIcon = (HICON)LoadImage(hModule, MAKEINTRESOURCE(-index), IMAGE_ICON, 0, 0, 0); m_bmp = new Gdiplus::Bitmap(hIcon); DestroyIcon(hIcon); } } break; case icoFile: m_bmp = new Gdiplus::Bitmap(T2W_SM(file.c_str())); break; default: HICON hIcon = NULL; ExtractIconEx(file.c_str(), index, NULL, &hIcon, 1); m_bmp = new Gdiplus::Bitmap(hIcon); DestroyIcon(hIcon); break; } if (m_bmp->GetLastStatus() != Gdiplus::Ok) { delete m_bmp; m_bmp = NULL; return; } }
HRESULT ISmileyBase::GetTooltip(BSTR *bstrHint) { if (bstrHint == NULL) return E_POINTER; *bstrHint = SysAllocString(T2W_SM(m_smltxt)); return S_OK; }