Professional UI Solutions
Site Map   /  Register


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 » CExtGridWnd and multiline text Collapse All
Subject Author Date
Anthony Spring Oct 25, 2006 - 8:26 AM

I have a grid with a series of columns.
The final column in the grid contains multiline text.
The text is made multiline through the use of carrage returns (\r\n) or through the use of __EGCS_EX_WRAP_TEXT.
This works fine.

The next step is to have each row in the grid have it’s own unique height based on the text in the final column.
This is acheived by creating an outer left header which is set to a width of 0.
Then after the grid is populated (or after the grid has been resized) the height of the text in the final column is measured, as used as the value to set the outer left cell’s extent to.

This gets weird results:
1) If I set the extents and never call m_wndGrid.OnSwUpdateScrollBars() then the extents are set fine, and the height of the rows are as expected but no scrollbars are shown
2) If I attempt to call m_wndGrid.OnSwUpdateScrollBars() after updating the heights, then the scrollbars flash for a second, and then the rows all collapse to their original (one text line high) heights.
3) If I attempt to call m_wnd_Grid.OnSwDoRedraw() after updating the heights, the same problem as #2 is observed.
4) The exception to 2 and 3 is that if the rows themselves never extend outside of the viewable area, then they sometimes display properly resized. No scrollbars are displayed since they aren’t necessary.

Any help would be greatly appreciated.

Technical Support Oct 26, 2006 - 6:16 AM

The following code is enough to update the scrolling information:

The problem may be caused by several factors. First, the grid window should support rows of variable height. So make sure that the __EGBS_FIXED_SIZE_ROWS style is not applied (you cam modify the style using the SiwModifyStyle() method). The grid window keeps the height of each row in its header cells. That means you should initialize one header column on the left with the OuterColumnCountLeftSet() and instantiate CExtGridCellHeader cell objects when initializing grid rows. You can set the minimum/maximum/current height for each row using the ExtentSet() method of header cells. To set the height of the row which is equal to the height of the content, just use the CExtGridWnd::BestFitRow() method.

Anthony Spring Oct 26, 2006 - 7:24 AM

I do not have __EGBS_FIXED_SIZE_ROWS set, and I have one header column to the left set with OuterColumnCountLeftSet()

		// Initialize our provider
		m_Grid.SetDataProvider( &m_DataProvider );

		// Set the header row count
		m_Grid.OuterRowCountTopSet( NUM_STATIC_ROWS, false );
		m_Grid.OuterColumnCountLeftSet( NUM_STATIC_COLS, false );
		m_Grid.OuterColumnWidthSet( true, 0L, 0 );



The rows resize correctly... unless the rows extend outside the visible area. If they do expand outside of the visible area then they all collapse back to their normal 1 text line height.

I can test this because I added an OnDoubleClickRow callback which just contains:
void MultilineDlg::OnGridDblClick( NMHDR* pNMHDR, LRESULT* pRes )
	CExtNotificationGridWnd::NHMDRClick *pNM = (CExtNotificationGridWnd::NHMDRClick *)pNMHDR;
	CExtGridHitTestInfo		htInfo( *(pNM->pPoint) );

	m_Grid.HitTest( htInfo, false, false, false );

	m_Grid.BestFitRow( htInfo.m_nRowNo );


Technical Support Oct 26, 2006 - 10:10 AM

Would you send a test project to us so we can quickly figure out what’s wrong? Another option is to change a grid in SimpleGrids or ProfUIS_Controls samples in order to reproduce the problem. In any case we need some test project that demonstrates the problem.

Anthony Spring Oct 26, 2006 - 11:31 AM

I have just realized that the popping of the sizes of the rows back down to nothing is likely a side effect of an extension we made to CExtGridWnd and likely not your problem. Sorry for the confusion.

However the following issues still exist as shown in the example application I have e-mailed you.

Text wrapped cells are not best fit to their wrapped size, but to their size before wrapping.
If you have rows of differing heights, it’s impossible to scroll to the bottom in one drag when using item by item scrolling vertically.

Fabien Masson Oct 26, 2006 - 2:36 AM

Dear ProfUIS Team,

I’m not sure of the way you like minor patchs submission, please let me for next time.
Best regards,

1st ... extract of Prof-UIS code in --- CSize CExtGridCell::MeasureCell(CExtGridWnd * pWndGrid, CDC & dcMeasure) const --- method:

CRect rcCellTextMeasured( 0, 0, 0, 0 );
    if( pWndGrid != NULL && (dwCellStyleEx&__EGCS_EX_WRAP_TEXT) != 0L )
        nDrawTextFlags |= DT_WORDBREAK;
        rcCellTextMeasured = CRect( 0, 0, 24000, 100 );

This CRect could not be set 24000 of width ... BEWARE, it works only with "one line of header" and "__EGCS_EX_WRAP_TEXT" style applied to a particular cell (it suits my needs and I’m sure that ProfUIS team have a better way for handling it! )
So, I replace this part of code with the correct width extent of that column :
CRect rcCellTextMeasured( 0, 0, 0, 0 );
    if( pWndGrid != NULL && (dwCellStyleEx&__EGCS_EX_WRAP_TEXT) != 0L )
        nDrawTextFlags |= DT_WORDBREAK;
        rcCellTextMeasured = CRect( 0, 0, 24000, 100 );

        // CAMBOS patch for its own use - ugly, but I couldn’t figure where to get the width of that column by a direct way

        // First - find the correct row & cell
        LONG nColCC, nRowCC;
        LONG nColFindCC, nRowFindCC;
        nColFindCC = -1;
        nRowFindCC = -1;
        for( nColCC = 0; nColCC < pWndGrid->ColumnCountGet(); nColCC++ )
            for (nRowCC = 0; nRowCC < pWndGrid->RowCountGet(); nRowCC++)
                const CExtGridCell * pCell = pWndGrid->GridCellGet( nColCC, nRowCC );
                if( pCell == NULL )
                if (pCell == this)
                    nColFindCC = nColCC;
                    nColCC = pWndGrid->ColumnCountGet();
                    nRowFindCC = nRowCC;
                    nRowCC = pWndGrid->RowCountGet();

        // Second - ask header (outer) which is the current extent stored for measuring text correctly
        // Remarks, it works only in the case we use one Outer Top Row for headers
        if ((nColFindCC != -1) && (nRowFindCC != -1) && (pWndGrid->OuterRowCountTopGet() == 1))
            const CExtGridCell * pCell = pWndGrid->GridCellGetOuterAtTop(nColFindCC, 0);
            if( pCell != NULL )
                int nWidthExtentCC;
                pCell->ExtentGet(nWidthExtentCC, 0); // Current size

                rcCellTextMeasured = CRect(0, 0, nWidthExtentCC, 10000);
        // End of patch

2nd. Increment cy and not cx in the same previous method
It was : = max(, nAlignHeight ); += 4;

Then I replace it with : = max(, nAlignHeight );
// CAMBOS changes
// += 4; += 4;
// End of changes

Hope this helps.

Technical Support Oct 26, 2006 - 12:12 PM

Thank you for reporting the bug. You are absolutely right. We have just fixed it. If you need the bug-fix please contact us via e-mail.

Anthony Spring Oct 25, 2006 - 1:40 PM

I have managed to get it almost working now.

Using both CExtGridWnd::BestFitRow() or using a special method of my creation which will adjust the extent of the outer left header based on the height as measured with CExtGridCell::OnMeasureBestFitExtent it seems that the height is always set to the height of the text BEFORE the text is wrapped.

Is there a way to measure the height of the wrapped text?

Thanks in advance.

Anthony Spring Oct 25, 2006 - 2:05 PM

I should note that it almost works.

If the cells reach beyond the visible range, and I click and drag the scroll bars, then as the scroll bar goes down, the cells at the top go back to being their initial one line of text high height.

Once the cells have shrunk in this way the scroll bar’s arrow buttons at the top and bottom disappear, and the scroll bar which i was dragging becomes unresponsive.

I plan to create a small demonstration application as soon as I can to illustrate the problem.

Fabien Masson Oct 25, 2006 - 9:53 AM

Finally, it was worthing to step debugging in internal methods of ProfUIS.

I could achieve my goal by using a left outer column size to 0 width (it works well too with a right outer one, tested) and by setting each line a minimum and a maximum height extent.
Everything then works like a charm, inclunding my ellipsis.

Hope it will help you as well.

Following are my init of cextgridwnd :
        __ESIS_STH_PIXEL    // IMPORTANT: horizontal scrolling strategy
        |__ESIS_STV_ITEM    // IMPORTANT: vertical scrolling strategy
        |__EGBS_RESIZING_CELLS_OUTER //Resizing of columns and rows by dragging the borders of the outer cells

    m_list_NOTE.OuterColumnCountLeftSet( 1 );
    m_list_NOTE.OuterColumnWidthSet(true, 0, 0);

Fabien Masson Oct 25, 2006 - 8:46 AM

Sorry, not an answer.

I was looking for the same functionality, except I would like to limit the heiht of the row: for example, 1 to 4 lines OK, more than 4 lines then display an ellipsis.
For the moment, I could have all these rows set to 4 lines of height with the ellipsis if needed (using DefaultRowHeightSet) and header limit to normal height (using OuterRowHeightSet).

Any help will be welcomed.


Suhai Gyorgy Oct 25, 2006 - 8:40 AM

It’s just a guess, but check if dynamic resizing styles are set or not: If __EGBS_DYNAMIC_RESIZING_V is set, then that must be the reason why grid is resizing your rows. To make sure it is not set, please call SiwModifyStyle(0L, __EGBS_DYNAMIC_RESIZING); on your grid.

Anthony Spring Oct 25, 2006 - 9:14 AM

My grid has the following styles set, and experiences the above problems.