Accessing a Pane's Icon |
Post Reply |
Author | |
mrmathis
Senior Member Joined: 17 May 2007 Location: United States Status: Offline Points: 105 |
Post Options
Thanks(0)
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
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
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 |
|
mrmathis
Senior Member Joined: 17 May 2007 Location: United States Status: Offline Points: 105 |
Post Options
Thanks(0)
|
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
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
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 |
|
mrmathis
Senior Member Joined: 17 May 2007 Location: United States Status: Offline Points: 105 |
Post Options
Thanks(0)
|
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
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |