- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
void foo()
{
if (!wxFile::Exists(defDir + resourcePath)) return false;
HBITMAP *bmp = new HBITMAP;
wxString path = defDir + resourcePath;
(*bmp) = (HBITMAP)LoadImage(0, path.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
if (bmp != NULL) (*pMap)[resourceName] = bmp; else return false;
return true;
}
bool SXXXXBitmapStorage::releaseItem(wxString resourceName)
{
ScrollBitmapHash::iterator iterator = pMap->find(resourceName);
if (iterator == pMap->end()) return false;
if (iterator->second != NULL) delete (HBITMAP*)iterator->second;
pMap->erase(resourceName);
return true;
}
HDC* SXXXXBitmapStorage::adjustToDC(wxString resourceName)//we must delete this object
{
HBITMAP *bmp = this->getItem(resourceName);
if (bmp == NULL) return NULL;
HDC *pDC = new HDC();
(*pDC) = CreateCompatibleDC(0);
SelectObject(*pDC, *bmp);
return pDC;
}
И вы не поверите, этот код работал! Правда, конечно же, была утечка ресурсов