Next part of tree state icon patches

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54343 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2008-06-24 12:48:01 +00:00
parent dea482c985
commit 4754ab1630
10 changed files with 899 additions and 9 deletions

View File

@@ -2691,6 +2691,43 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
// notify us before painting each item
*result = m_hasAnyAttr ? CDRF_NOTIFYITEMDRAW
: CDRF_DODEFAULT;
// windows in TreeCtrl use one-based index for item state images,
// 0 indexed image is not being used, we're using zero-based index,
// so we have to add temp image (of zero index) to state image list
// before we draw any item, then after items are drawn we have to
// delete it (in POSTPAINT notify)
if (m_imageListState && m_imageListState->GetImageCount() > 0)
{
#define hImageList (HIMAGELIST)m_imageListState->GetHIMAGELIST()
// add temporary image
int width, height;
m_imageListState->GetSize(0, width, height);
HBITMAP hbmpTemp = ::CreateBitmap(width, height, 1, 1, NULL);
int index = ::ImageList_Add(hImageList, hbmpTemp, hbmpTemp);
::DeleteObject(hbmpTemp);
if ( index != -1 )
{
// move images to right
for ( int i = index; i > 0; i-- )
::ImageList_Copy(hImageList, i, hImageList, i-1, 0);
// we must remove the image in POSTPAINT notify
*result |= CDRF_NOTIFYPOSTPAINT;
}
#undef hImageList
}
break;
case CDDS_POSTPAINT:
// we are deleting temp image of 0 index, which was
// added before items were drawn (in PREPAINT notify)
if (m_imageListState && m_imageListState->GetImageCount() > 0)
m_imageListState->Remove(0);
break;
case CDDS_ITEMPREPAINT: