示例#1
0
文件: ltab.cpp 项目: jcbaar/ClassLib
// Get the minimum size.
BOOL ClsLTab::OnGetMinSize( ClsSize& szMinSize )
{
	// Adjust an empty rectangle to include the
	// tab and frame sizes.
	ClsRect rc( 0, 0, 0, 0 );
	AdjustRect( TRUE, rc );

	// We need two pixels of extra room on the tab-side. We need
	// this because the TCM_ADJUSTRECT message creates a rectangle
	// which is two pixels closer to the tabs than to the other
	// rectangle sides.
	DWORD dwStyle = GetStyle();
	if (( dwStyle & TCS_BUTTONS ) != TCS_BUTTONS )
	{
		// When we are vertical we grow two pixels
		// wider. Otherwise we grow two pixels higher.
		if ( dwStyle & TCS_VERTICAL ) rc.Right()  += 2;
		else			      rc.Bottom() += 2;
	}

	// The size of the resulting rectangle is the
	// total size of the tabs including frames etc.
	szMinSize = rc.Size();

	// Iterate the members.
	ClsTMember *pMember;
	int cx = 0, cy = 0;
	for ( pMember = m_Members.GetFirst(); pMember; pMember = m_Members.GetNext( pMember )) 
	{
		// Initialize structure.
		ClsSize sz( 0, 0 );
		
		// Get dimensions.
		if ( pMember->m_pMember->OnGetMinSize( sz )) 
		{
			// Any larger values?
			if ( sz.CX() > cx ) cx = sz.CX();
			if ( sz.CY() > cy ) cy = sz.CY();
		}
	}

	// Store values.
	szMinSize.Add( cx, cy );
	return TRUE;
}