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 » BestFitColumn call for uninitialized grid Collapse All
Subject Author Date
Suhai Gyorgy Dec 6, 2006 - 9:20 AM

Dear Support,

I’m trying to make a simple grid to look like a ListBox. For this purpose I made the following class:

class CExtFormListBox : public CExtGridWnd
{
public:
	int AddString(LPCTSTR lpszItem) 
	{ 
		if (ColumnCountGet() <= 0) ColumnAdd(1, false);
		RowAdd(1, false);
		int iNewIndex = RowCountGet()-1;
		GridCellGet( 0, iNewIndex, 0, 0, RUNTIME_CLASS(CExtGridCell) )->TextSet(lpszItem);
		BestFitColumn(0); 
		return iNewIndex;
	}
};
I only call this AddString function from other place, no other type of initialization is done. My problem is with BestFitColumn. Around the end of this BestFitColumn method there’s this code segment:
				INT nExtentMin, nExtentMax;
				pCell->ExtentGet( nExtentMin, -1 );
				pCell->ExtentGet( nExtentMax, 1 );
				if( nBestFitExtent < nExtentMin )
					nBestFitExtent = nExtentMin;
				if( nBestFitExtent > nExtentMax )
					nBestFitExtent = nExtentMax;
				pCell->ExtentSet( nBestFitExtent );
Before the code gets to this part, nBestFitExtent is 8 (measured by the text in it). Both ExtendGet calls return false and both nExtentMin and nExtentMax stays to be 0xcccccccc. In my case this results in setting 0xcccccccc in ExtentSet and I have 0 wide cells, even though width should be 8. Could you fix this code and check return code of ExtentGet?

Thank you:
Chris

Technical Support Dec 6, 2006 - 1:32 PM

The best fit feature requires an outer header row (for instance at the top) and header cells in it (for instance CExtGridCellHeader). You can hide the header row if needed (set the zero height with CExtGridWnd::OuterRowHeightSet()).

The best fit feature may make your list box like window having the horizontal scroll bar. We guess the automatic proportional resizing of the column can be used instead.

Suhai Gyorgy Dec 7, 2006 - 4:21 AM

I want to have horizontal scrollbar and also vertical (when needed). With outer header row I could get BestFitColumn to work. For testing purposes I didn’t set the outer row’s height to zero yet, so I can see the column is as wide as I’d like it to be. But still, i have neither vertical, nor horizontal scrollbar. I even called OnSwRecalcLayout( true ); OnSwUpdateScrollBars(); OnSwDoRedraw(); , but still no scrollbar (actually I stepped into BestFitColumn while debugging, and these above methods are called from there as well). I checked available styles, methods, overridables in all classes CExtGridWnd is derived from, tried setting WS_VSCROLL|WS_HSCROLL styles, still no luck. What am I missing?

Thank you:
Chris

Technical Support Dec 7, 2006 - 1:27 PM

You don’t need the WS_HSCROLL|WS_VSCROLL styles. You should apply the __ESIS_STH_PIXEL|__ESIS_STV_ITEM styles using CExtScrollItemWnd::SiwModifyStyle(). This will make your grid pixel-by-pixel scrollable horizontally and item-by-item scrollable vertically. You can send us the source code of your grid so we can find out what’s wrong.

Suhai Gyorgy Dec 8, 2006 - 1:48 AM

I did try that already, without any luck. I’m sending you the code by e-mail.