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 » Image in a string cell Collapse All
Subject Author Date
Offer Har Feb 1, 2007 - 10:00 AM

Dear Support,

We need a cell with text and an image to the left of it, much like the combo-box cell, but a normal string cell.
I could not find any sample or implementation of such.

Best Regards,
Ron.

Technical Support Feb 1, 2007 - 11:32 AM

Any grid cell supports an icon. The grid window can keep an array of icon objects and a grid cell can keep the index of an icon in that array. Here is the list of relevant methods:

INT CExtGridWnd::GridIconGetCount() const
CExtCmdIcon * CExtGridWnd::GridIconGetAt( INT nIdx )
const CExtCmdIcon * CExtGridWnd::GridIconGetAt( INT nIdx ) const
INT CExtGridWnd::GridIconInsert( // returns index or -1
    CExtCmdIcon * pIcon,
    INT nIdx, // = -1 // append
    bool bCopyIcon // = true
    )
INT CExtGridWnd::GridIconInsert( // returns index or -1
    const CExtCmdIcon * pIcon,
    INT nIdx, // = -1 // append
    bool bCopyIcon // = true
    )
INT CExtGridWnd::GridIconRemove(
    INT nIdx, // = 0
    INT nCountToRemove // = -1 // all
    )
INT CExtGridCell::IconIndexGet() const
INT CExtGridCell::IconIndexSet(
    INT nIconIndex // = -1 // -1 - remove icon
    )
If the icon index is less than zero (by default), no icon is displayed in the cell.

BTW The same design is applicable for fonts.

Offer Har Feb 1, 2007 - 1:41 PM

Dear Support,

Lets say i want to set an icon to a cell how do i do it? I would like the cell to keep showing the text i set to it.

I see that IconIndexSet in CExtGridCell does nothing, and m_nIconIndex is not used anywhere.

What cell type should i use to have an icon and a text?

Thanks,
Ron.

Suhai Gyorgy Feb 2, 2007 - 3:38 AM

I tried this in ProfUIS_Controls sample’s Grid page. I just had to add 2 lines of code:
- In CPageGrid::OnInitDialog I added the line
    m_wndGrid.GridIconInsert(g_CmdManager->CmdGetIconPtr(g_CmdManager->ProfileNameFromWnd(m_hWnd), ID_EDIT_COPY));
right after m_wndGrid.SiwModifyStyleEx(...) call.

- In CPageGrid::_InitColumnText, where all the CExtGridCellString cells are inititalized, I added the line
    pCellString0->IconIndexSet(0);
right after pCellString0->TextSet( _T("Cell1") ); call.

Compile and run, you can see the usual Copy icon in the first cell of the appropiate column, next to the text "Cell1".

To use an image that you have in resource as ICON type, you can use the following code to insert it to the grid (again tried in ProfUIS sample):

	CExtCmdIcon icon;
	icon.AssignFromHICON(LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_EDIT)), true);
	m_wndGrid.GridIconInsert(&icon);
and the same code to assign the icon to the cell.