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 » PageRemove() causing crashes. Collapse All
Subject Author Date
Debabrata Mukherjee Oct 3, 2007 - 6:07 AM

Hi Support,

I try to remove multiple pages from the CextTabPageContainerWnd. using the method PageRemove(Idex,no.from index,TRUE). But this crashes in both ProfUIS 2.54 and 2.80 . Any pointers into what may be going wrong.

If I do single pageRemoval in a loop, this works fine.

One more query is : Can I Remove a page from the TabPageContainerWnd and not select the previous tab by default. i.e. if i remove the page with index 9, i donot want the 8 to be selected.Can it be done?

Please suggest ASAP.

Thanks

Technical Support Oct 3, 2007 - 12:43 PM

We tested the CExtTabPageContainerWnd::PageRemove() and found no problems with it. But anyway we have changed this method to make it safer. So now any crashes are simply impossible.

Here is the modified code:

LONG CExtTabPageContainerWnd::PageRemove( 
	LONG nIndex,
	LONG nCountToRemove, // = 1
	bool bDestroyPageWnd // = true
	)
{
	ASSERT_VALID( this );
	if( nIndex > m_pWndTab->ItemGetCount() - 1L )
		return 0L;

LONG nCountRemoved = 0L; // returns count of removed items

LONG nCount = m_pWndTab->ItemGetCount();
LONG nAvailToRemove = nCount - nIndex;

	if( nCountToRemove > nAvailToRemove )
		nCountToRemove = nAvailToRemove;

	for( LONG i = 0L; i < nCountToRemove; i++ )
	{
		HWND hWnd = (HWND) m_pWndTab->ItemLParamGet( nIndex );
		if(		hWnd != NULL 
			&&	::IsWindow( hWnd )
			)
		{
			::ShowWindow( hWnd, SW_HIDE );
			if(	bDestroyPageWnd )
				::DestroyWindow( hWnd );
		}
		if( m_pWndTab->ItemRemove( nIndex, 1L, false ) > 0L )
			nCountRemoved++;
	}

	nCount = m_pWndTab->ItemGetCount();
	for( i = 0L; i < nCount; i++ )
		::SetWindowLong(
			(HWND)m_pWndTab->ItemLParamGet(i),
			GWL_ID,
			0x101 + i
			);

	// select previous page
	if( nCount > 0L )
	{
		if( nIndex > 0L )
			nIndex--;
		PageSelectionSet( nIndex );
	}

	_RepositionBarsImpl();

	if( nCountRemoved > 0L )
		m_pWndTab->UpdateTabWnd( true );

	return nCountRemoved;
}

Suhai Gyorgy Oct 3, 2007 - 9:14 AM

True, PageRemove really seems a bit messy when second parameter is bigger than 1. I’m sure Support will soon fix it, in the meanwhile remove the pages with a loop.

If you don’t want the previous page selected, which page would you like selected? One of the pages have to be selected at all times. If you want the last page selected, you can do that by calling PageSelectionSet(PageGetCount() - 1); right after PageRemove ( or after the loop with PageRemove in it ). Or select the first page by calling the same method with 0 as parameter.