- Added cleanup routine for ImageList

- Fixed memory leak in ComboBoxTestModel
This commit is contained in:
andre@woesten.com 2008-11-03 13:00:37 +00:00
parent ac7cb4081f
commit 2648ed168a
4 changed files with 24 additions and 2 deletions

View File

@ -59,7 +59,8 @@ private:
std::vector<uistring> list;
win32cpp::ImageList* il;
public:
ComboBoxTestModel() {
ComboBoxTestModel()
{
il = new win32cpp::ImageList(16, 16, win32cpp::ImageList::Color32);
il->Add(_T("resources\\test_combobox.bmp"));
@ -70,6 +71,11 @@ public:
list.push_back(_T("test"));
}
~ComboBoxTestModel()
{
delete il;
}
virtual win32cpp::ImageList* ImageList()
{
return il;

View File

@ -50,6 +50,9 @@ model(ComboBox::sNullModel)
{
}
ComboBox::~ComboBox()
{
}
HWND ComboBox::Create(Window* parent)
{

View File

@ -66,6 +66,7 @@ public:
typedef sigslot::signal1<ComboBox*> SelectionChangedEvent;
ComboBox();
~ComboBox();
void SetModel(ModelRef model);
int Selected();

View File

@ -59,6 +59,18 @@ ImageList::ImageList(int width, int height, ImageList::ColorDepth depth) :
ImageList::~ImageList()
{
for(int i = 0; i < this->Count(); i++) {
IMAGEINFO info;
this->Info(i, &info);
DeleteObject(info.hbmImage);
if(info.hbmMask) DeleteObject(info.hbmMask);
this->Remove(i);
}
::ImageList_Destroy(this->imagelistHandle);
}
HIMAGELIST ImageList::Handle() const
@ -73,7 +85,7 @@ int ImageList::Count() const
int ImageList::Add(HBITMAP image)
{
return ::ImageList_Add(this->imagelistHandle, image, image);
return ::ImageList_Add(this->imagelistHandle, image, NULL);
}
int ImageList::Add(const uistring& filename, bool transparence)