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 General Discussion » DrawItem in CExtGridCellComboBox Collapse All
Subject Author Date
Douglas Hoppes Aug 19, 2009 - 1:48 PM

Hi all,

I’m not sure how to do this. In my MFC code, I override the DrawItem method of CComboBox, so that I can paint some very specific fonts into the drop list.

How do I do this with the CExtGridCellComboBox?

Doug

Technical Support Sep 2, 2009 - 1:01 PM

You should implement the following virtual method of the CExtGridCell class for measuring and re-painting the cell’s text area:

       virtual CSize OnMeasureTextSize(
            const CExtGridWnd & wndGrid,
            CDC & dc,
            LONG nVisibleColNo,
            LONG nVisibleRowNo,
            LONG nColNo,
            LONG nRowNo,
            INT nColType,
            INT nRowType,
            const RECT & rcCellExtra,
            const RECT & rcCell,
            const RECT & rcCellText,
            DWORD dwAreaFlags
            ) const;
      virtual void OnPaintText(
            const RECT & rcCellText,
            const CExtGridWnd & wndGrid,
            CDC & dc,
            LONG nVisibleColNo,
            LONG nVisibleRowNo,
            LONG nColNo,
            LONG nRowNo,
            INT nColType,
            INT nRowType,
            const RECT & rcCellExtra,
            const RECT & rcCell,
            const RECT & rcVisibleRange,
            DWORD dwAreaFlags,
            DWORD dwHelperPaintFlags
            ) const;


Douglas Hoppes Aug 31, 2009 - 8:34 AM

Thanks for the help with the combo box. I was able to sub-class my combo-box and show my individual images in the drop-down list. So, when I pass a DWORD value, I can go to my font file and actually display a replacement icon for the DWORD, which is great.

The final issue that I have with this is that owner drawn image that is present in the droplist is not present in the cell. For example, if the DWORD value = 3, I show a "Filled-in square" in my droplist. If I picked that "Filled-in Square", the grid cell shows the value 3, not the "Filled-in Square".

Doug

Technical Support Sep 1, 2009 - 9:58 AM

You shoul implement the following virtual methods of the CExtGridCell class to paint your image instead of built-in grid cell icon:

 virtual void OnPaintIcon(
            const CExtCmdIcon * pIcon,
            const RECT & rcIcon,
            const CExtGridWnd & wndGrid,
            CDC & dc,
            LONG nVisibleColNo,
            LONG nVisibleRowNo,
            LONG nColNo,
            LONG nRowNo,
            INT nColType,
            INT nRowType,
            const RECT & rcCellExtra,
            const RECT & rcCell,
            const RECT & rcVisibleRange,
            DWORD dwAreaFlags,
            DWORD dwHelperPaintFlags
            ) const;
      virtual CSize IconGetSize() const;


Douglas Hoppes Sep 2, 2009 - 9:19 AM

That’s excellent! Works beautifully! One final question: Now, my combobox shows the list of my owner draw items and I can see the owner drawn item in the grid control. However, the text data in the combobox still shows. Is there a way of not having it show?

Doug

Technical Support Aug 19, 2009 - 2:35 PM

The CComboBox and CExtComboBox classes are wrappers for the combo box common control. The CExtGridCellComboBox class is the non HWND-based UI element which implements combo box like looking grid cell. The combo box window and combo box grid cell are two absolutely different UI element which are not based on each other. We have the CExtGridCellFontFaceName class which is derived from the CExtGridCellComboBox class and implements the font face picker cell. This class probably the ready to use solution for you or at least you can use its source code as a sample.


Douglas Hoppes Aug 31, 2009 - 8:57 AM

Thanks for the help with the combo box. I was able to sub-class my combo-box and show my individual images in the drop-down list. So, when I pass a DWORD value, I can go to my font file and actually display a replacement icon for the DWORD, which is great.

The final issue that I have with this is that owner drawn image that is present in the droplist is not present in the cell. For example, if the DWORD value = 3, I show a "Filled-in square" in my droplist. If I picked that "Filled-in Square", the grid cell shows the value 3, not the "Filled-in Square".

Doug