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 General Discussion » CExtReportGridWnd minimal width and height Collapse All
Subject Author Date
Sergey Serebryakov Jun 3, 2009 - 10:58 PM

Hello,

How can I get or compute the minimal height of the CExtReportGridWnd derived control in order to display all its content without need to use the scrollbars.
The use of RowCountGet() * DefaultRowHeightGet() does not work since rows have different height,

Thanks a lot.

Technical Support Jun 4, 2009 - 4:45 AM

The following code snippet computes the height of a report grid window as the total height of header row(s) at top, data rows, horizontal scroll bar and report grid’s non-client area:

CExtReportGridWnd & wndRG = . . .
LONG nIndex, nCount;
// header rows at top
LONG nTopHeight = 0;
            nCount = wndRG.OuterRowCountTopGet();
            for( nIndex = 0; nIndex < nCount; nIndex ++ )
            {
                        INT nRowHeight = wndRG.OuterRowHeightGet( true, nIndex );
                        nTopHeight +=  nRowHeight;
            }
// data rows (only expanded scrollable rows are computed)
LONG nDataHeight = 0;
            nCount =  wndRG.RowCountGet();
            for( nIndex = 0; nIndex < nCount; nIndex ++ )
            {
                        INT nExtraSpaceBefore = 0, nExtraSpaceAfter = 0;
                        INT nRowHeight = wndRG.OnSiwQueryItemExtentV( nIndex, &nExtraSpaceBefore, &nExtraSpaceAfter );
                        nTopHeight +=  nRowHeight + nExtraSpaceBefore + nExtraSpaceAfter;
            }
// non-client area
CRect rcWnd, rcClient;
            wndRG.GetWindowRect( &rcWnd );
            wndRG.GetClientRect( &rcClient );
LONG nNonClientAreaHeight =  rcWnd.Height() - rcClient.Height();
// horizontal scroll bar if present and if it’s window (not a non-client area part)
LONG nSbhHeight = 0;
            if( wndRG.OnSwHasScrollBar( true ) )
            {
                        CScrollBar * pSBH = wndRG.GetScrollBarCtrl( SB_HORZ );
                        if( pSBH->GetSafeHwnd() != NULL && ( pSBH->GetStyle() & WS_VISIBLE ) != 0 )
                        {
                                    CRect rcSBH;
                                    pSBH->GetWindowRect( &rcSBH );
                                    nSbhHeight =  rcSBH.Height();
                        }
            }
// result
LONG nReportGridHeight =  nTopHeight + nDataHeight +  nNonClientAreaHeight + nSbhHeight;
The above code assumes the report grid’s layout has been updated after initialization. So, if you invoke it at startup immediately after report grid initialization, you should invoke the wndRG.OnSwRecalcLayout( true ); line of code before the code above to update report grid’s layout.