Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Icon and text in CExtGridCell Collapse All
Subject Author Date
Paul Boswell Dec 23, 2008 - 10:58 AM

I saw that you had a post earlier about creating a CExtGridCell with an icon and text. However, it didn’t contain quite enough information for me to implement it:


http://www.prof-uis.com/prof-uis/tech-support/support-forum/cextpropertygridctrl-how-to-add-a-cell-that-has-both-a-string-and-a-bitmapicon-4149.aspx#@lt;/p>

I would like to add the icons as per the first method described where each CExtGridCell keeps track of its own icons. In the post, the technical support person recommended overriding the IconGet function so that it returns the desired icon.


So I overrode the function, but when the overridden CExtGridCell is displayed, the IconGet function is never called. What’s missing?


 


By the way - the search bar on the support forum page seems to only search keywords with the "OR" operation (maybe there is a way to search that I don’t know about?) . So if you want to narrow your results, the only thing you can do is reduce the number of words you enter in. That makes it very time consuming to find the answer you’re looking for because you have to enter in single words that could be quite broad. Just a suggestion.

Paul Boswell Dec 23, 2008 - 11:57 AM

It looks like I can override IconGet() just fine, but the function is really only called within the base class (CExtGridCell::OnPaintForeground) anyway, so my override isn’t doing anything.


Do you have any ideas for how to make this work?

Technical Support Dec 24, 2008 - 1:30 PM

You can use the following methods of CExtGridCell to get the icon:

   virtual CExtCmdIcon * IconGet();
            const CExtCmdIcon * IconGet() const;
Please ensure you have overridden the first method because the second one is not virtual. The IconGet() virtual method is really invoked when the icon should be painted but it’s also invoked from the following virtual method:
   virtual CSize IconGetSize() const;
You can override the IconGetSize() virtual method if you need to make the icon area smaller or larger. The icon area inside the grid cell is never used as a clickable or selectable area. So the icon is just a visual element. The IconGetSize() method is used for computing the size of the icon and the CExtGridCell::OnPaintIcon() method is used for painting the icon. You can implement the IconGetSize() and CExtGridCell::OnPaintIcon() virtual methods and draw something inside the icon area. For instance, the CExtGridCellColor color picker cell draws a color box instead of an icon and the CExtGridCellFontFaceName font name picker cell draws a font preview.