Print Page | Close Window

ImageManager issue in 11.2.1

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=8991
Printed Date: 14 November 2025 at 8:13am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: ImageManager issue in 11.2.1
Posted By: pavold
Subject: ImageManager issue in 11.2.1
Date Posted: 03 December 2007 at 8:27am
Hi,

After upgrading to toolkitpro 11.2.1, I have encountered a problem.

We are using CXTPImageManager to load icons for a treeview control.

Here is the code:

CImageList m_ImageList;
m_ImageList.Create(16, 16, ILC_MASK | ILC_COLOR32, 0, 0);

<...>

CXTPImageManagerIconSet*pIconSet=XTPImageManager()->GetIconSet(nIcon);
        if(pIconSet==0)
        {
            return false;
        }

        CXTPImageManagerIcon* pIcon=pIconSet->GetIcon(16);
        if(pIcon==0)
        {
            return false;
        }

        m_ImageList.Add(CBitmap::FromHandle(pIcon->GetIcon().GetBitmap()), (CBitmap*)0);

The actual images are loaded to the image manager from a 32-bit png-file.

This worked fine with the version 11.1.3 . Now I cannot see any icons in the treeview.
Debugging showed that I get valid (not null) iconset and an icon. Event GetIcon().GetBitmap() seems to return a valid handle.

I've seen that the release notes mention some ImageManager changes, but I was not able to figure out what to do.

Best Regards,
Pavol



Replies:
Posted By: pavold
Date Posted: 03 December 2007 at 8:32am
Sorry for the misinformation. I have just found out that GetBitmap() returns 0.
How can I get a valid handle?


Posted By: Oleg
Date Posted: 03 December 2007 at 3:21pm
Hello,
 
See release notes - we modified imagemanager.   You can create copy of handle before access:
 
CXTPImageManagerIconHandle handle;
handle.CopyHandle(pIcon->GetIcon());
 
m_ImageList.Add(CBitmap::FromHandle(handle.GetBitmap()), (CBitmap*)0);
 
But think you can better use direct methods that load alpha bitmaps.
 
 
btw - CImageList supports 32bit alpha bitmaps only in WindowsXP, but CXTPImageManager for all OS.....


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: iamthewind
Date Posted: 16 December 2007 at 10:36pm
oleg, I have a question on this topic too.
I wish to using CXTPImageManager to load icons for a CXTTreeCtrl control,
but CXTTreeCtrl  only support CImageList:
CImageList* SetImageList(CImageList* pImageList, int nImageListType);
 
you said "CImageList supports 32bit alpha bitmaps only in WindowsXP, but CXTPImageManager for all OS.....",
but how could I use CXTPImageManager  for CXTTreeCtrl?
 
Thanks very much!


Posted By: Oleg
Date Posted: 17 December 2007 at 1:25am
Yes, CXTTreeCtrl  doesn't support ImageManager :(
You can manually draw icons in OnCustomDraw handler:
 

void CTreeViewCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
  NMTVCUSTOMDRAW* lpLVCD = reinterpret_cast<NMTVCUSTOMDRAW*>(pNMHDR);
 *pResult = CDRF_DODEFAULT;
 switch (lpLVCD->nmcd.dwDrawStage)
 {
 case CDDS_PREPAINT:
  *pResult = CDRF_NOTIFYITEMDRAW;
  break;
 case CDDS_PREPAINT | CDDS_ITEM:
  {
   *pResult |= CDRF_NOTIFYPOSTPAINT;
break;
  }
 case CDDS_POSTPAINT | CDDS_ITEM:
 case CDDS_POSTPAINT | CDDS_ITEM  | CDDS_SUBITEM:
  {
...
 
   CXTPImageManagerIcon* pIcon = m_pIcons->GetImage(pItem->m_nIcon, m_nIconSize);
   
   if (!pIcon)
    pIcon = m_pIcons->GetImage(pItem->m_nIcon, ICON_SMALL);
   
   if (!pIcon)
    return;
   CRect rc(0, 0, 0, 0);
   GetTreeCtrl()->GetItemRect(pItem->m_hItem, rc, TRUE);
   
   if (!rc.IsRectEmpty())
   {
    XTPImageState imageState = xtpImageNormal;
    if (GetTreeCtrl()->GetItemState(hItem, TVIS_SELECTED) & TVIS_SELECTED)
     imageState = xtpImageHot;
    CPoint pt(rc.left - m_nIconSize - 2, (rc.top + rc.bottom - sz.cy) / 2);
    pIcon->Draw(CDC::FromHandle(lpLVCD->nmcd.hdc), pt, pIcon->GetIcon(imageState), sz);
   }
...
break;
  }
 }


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net