Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - ImageManager issue in 11.2.1
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ImageManager issue in 11.2.1

 Post Reply Post Reply
Author
Message
pavold View Drop Down
Newbie
Newbie


Joined: 14 May 2007
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote pavold Quote  Post ReplyReply Direct Link To This Post Topic: ImageManager issue in 11.2.1
    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
Back to Top
pavold View Drop Down
Newbie
Newbie


Joined: 14 May 2007
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote pavold Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
iamthewind View Drop Down
Newbie
Newbie


Joined: 11 September 2007
Location: China
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote iamthewind Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.059 seconds.