Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Docking Pane
  New Posts New Posts RSS Feed - Accessing a Pane's Icon
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Accessing a Pane's Icon

 Post Reply Post Reply
Author
Message
mrmathis View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 May 2007
Location: United States
Status: Offline
Points: 105
Post Options Post Options   Thanks (0) Thanks(0)   Quote mrmathis Quote  Post ReplyReply Direct Link To This Post Topic: Accessing a Pane's Icon
    Posted: 07 July 2009 at 12:49pm

In my app, I have a drop menu that allows selection of all the available docking panes.  Functionally, it is identical to the menu available in Visual Studio that lets you switch between source files.  Y'know, the little triangle icon with the bar over the top.  Anyway, I used the block of code below with Codejock 11.2 to set the icons on the CXTPPopupBar entries that represent each pane. 

                    if (CXTPImageManagerIcon* pIMIcon = pPane->GetIcon())
                        if (CXTPImageManagerIconHandle& IconRef = pIMIcon->GetIcon())
                            if ((HICON)IconRef)
                                pControl->SetCustomIcon((HICON)IconRef);
This doesn't work in Codejock 13.0.  I've debugged enough to see that the difference is in CXTPImageManagerIconSet::GetIcon, where the pIcon that is returned doesn't have the m_hIcon set in 13.  I tried stepping into the display of the tab in 13 to see how it finds the icon.  I can see it using m_pRInfo, but I'm not sure whether or how to access that myself.
 
A couple of notes:  I extract the icons from the pane in this way because 3rd party apps can add panes to my app and I don't have a master image list of all the possible icons.  My pane IDs exist in a separate space from the rest of my images, and combining them isn't a viable option because of the 3rd party option, as well as some legacy issues in my own app, so I can't just fall back on the standard image lookup.
 
Any solutions?
 
--Mike
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 08 July 2009 at 3:50am
Hi,
 
Yes, It was changed (see release notes)  - now by deafult all icons located on single bitmap to save GDI handlers. and ((HICON)IconRef) can return NULL.
Think most easy solution now is instead pControl->SetCustomIcon((HICON)IconRef);
call
 
pCommandBars->GetImageManager()->GetImage(nControlID)->Copy(pIMIcon) - it will copy and replace icon asociated with pControl.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
mrmathis View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 May 2007
Location: United States
Status: Offline
Points: 105
Post Options Post Options   Thanks (0) Thanks(0)   Quote mrmathis Quote  Post ReplyReply Direct Link To This Post Posted: 09 July 2009 at 12:10pm
As I tried to describe earlier, my docking pane IDs space is distinct from my command ID space, so I never add the pane icons to the global image manager.   Therefore, your suggestion won't work for me.  I've tried one other approach...
 
                    if (CXTPImageManagerIcon* pIcon = pPaneManager->GetIcon(nID))
                    {
                        CXTPImageManagerIconHandle& refIcon = pIcon->GetIcon();
                        if (HBITMAP hBitmap = refIcon.GetBitmap())
                        {
                            CBitmap bmpIcon;
                            bmpIcon.Attach(hBitmap);
                            HICON hIcon = CXTPTransparentBitmap(bmpIcon).ConvertToIcon();
                            CXTPImageManagerIconHandle hIconHandle;  // do not set equal to hIcon here or it will NOT destroy the icon
                            hIconHandle = hIcon; // Will call DestroyIcon;
                            pControl->SetCustomIcon((HICON)hIconHandle);
                        }
                    }
 
...but that isn't going well either.  First I get an assertion from CXTPImageManagerIconHandle::GetBitmap because the IsAlpha is false, then it hoses up the pane images on the screen and crashes shortly thereafter.  I copied that central block from a co-worker and I'm not sure it properly applies to this situation.  Is there any way I can massage this into something workable?  Is there any other way to get back a usable icon from the docking pane manager?
 
 
--Mike
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 10 July 2009 at 6:25am
Hi,
Strange. My suggestion have to work - it copis one image to another it doesn't depend on ID you have.
 
SetCustomIcon anyway is not good method for you  - it saves all copies of icons untill application terminated. You need replace old icon instead.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
mrmathis View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 May 2007
Location: United States
Status: Offline
Points: 105
Post Options Post Options   Thanks (0) Thanks(0)   Quote mrmathis Quote  Post ReplyReply Direct Link To This Post Posted: 11 July 2009 at 4:31pm
But I don't think I want to replace the old icon.  Here's an example of my issue with doing so:  Say I have a command "Smash*t" with ID 400 in my application.  It has an icon, and appears on my ribbon somewhere.  I also have a docking pane "FancyPane" with ID 400. 
 
(Aside: We can argue in hindsight whether using the same numbers was a good idea, but at the time those IDs evolved it wasn't perceived as any kind of an issue.  They were two completely separate worlds.  Those IDs have been published in my app for over 10 years - long before Codejock came into the picture.  Changing them is not a good option.) 
 
For my pane switching, I just create a pick-a-pane popup menu on the fly whose IDs match all the panes enumerate by the pane manager.  It doesn't matter that they also match commands in my system, since I'm tracking the menu myself, and when it terminates I have the pane ID I want to activate.  Now, if I follow your suggestion, I'll replace icon 400 in the global image manager with the one from the pane, right?  But won't that also affect the ribbon display of the unrelated Smash*t command?  Would I be able to replace, track my menu, and then reinstate the original image to that index without anything affecting my ribbon display?
 
--Mike
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.188 seconds.